C++ OBJECT ORIENTED PROGRAMMING 12. What will be the output of the following C++ code? #include...
Consider the following C++code snippet and what is the output of this program? # include<iostream> using namespace std; void arraySome (int[), int, int); int main () const int arraysize = 10; int a[arraysize]-1,2,3,4,5, 6,7,8,9,10 cout << "The values in the array are:" << endl; arraySome (a, 0, arraySize) cout<< endl; system ("pause") return 0; void arraySome (int b[], int current, int size) if (current< size) arraySome (b, current+1, size); cout << b[current] <<""; a) Print the array values b) Double...
7. What is the output of this code? Discuss about your answer #include <iostream> using namespace std: class CMyClass { public: static int m i: CMyClass myObjectl; CMyClass myObject2; CMyClass myObject3 int main) < myObject1.m i-1 my0bject2.m i = 3;
what is the output for the following code? explain the steps. /*#include <iostream> using namespace std; int f(int &i) { i = 10; return(5 * i); } int main() { int n = 5; f(n); cout << n << "\n"; return 0; } #include <iostream> using namespace std; int sub1(int n) { n--; return n; } int main() { int m = 10; for(int j = 0; j < 10; j++) m -= sub1(j); cout << m << "\n"; return...
2. What is the value of x alter the following code is executed # include<iostream> using namespace std; int main int t-0, c- 0,x-3; while (c < 4) t=t+x; cout << x return 0; a) 3 b) 21 c) 24 d) 48 3. What is the output of the following code? # include<iostream> using namespace std; int main0 int a- 3; for (int i 5; i >0; i) a a+i cout << a << “ “ return 0; d) 8...
Question 28 What is the output of the following program? Assume code is correct. #include <iostream> using namespace std; int main() { int i = 1,j,x = 5, y = 4; while (i <= y) { for (j = 0; j <= y2; j++) cout << 'Z'; cout << endl; i=i+1; } return 0; 3 B IV AA-I E333 X X, B, GT 12pt Paragraph
* The output of the following code is #include <iostream> using namespace std: int prod (int x, int y=3){ int d; int a=x*y; return (a); int main ({ cout << prod (7) <<" "<<prod (6, 4); return 0; 21 12 O 49 24 O 21 24 O 21 18
I need to do object oriented programming for c++. I had to make make a program where it would add,subtract,multiply,and divide fraction. I got that working, but it wont work for negative can anyone fix it and explain how they did it? Source.cpp code: #include "Fraction.h" #include <iostream> using namespace std; int main() { Fraction f1(-4, 6); Fraction f2(5, -9); Fraction sum = sum.add(f1, f2); sum.print(sum); Fraction diff = diff.subtract(f1, f2); diff.print(diff); ...
#include #include #include #include #include #include // NOLINT (build/c++11) #include class Clock { private: std::chrono::high_resolution_clock::time_point start; public: void Reset() { start = std::chrono::high_resolution_clock::now(); } double CurrentTime() { auto end = std::chrono::high_resolution_clock::now(); double elapsed_us = std::chrono::duration std::micro>(end - start).count(); return elapsed_us; } }; class books{ private: std::string type; int ISBN; public: void setIsbn(int x) { ISBN = x; } void setType(std::string y) { type = y; } int putIsbn() { return ISBN; } std::string putType() { return type; } }; std::ostream...
C++ ONLY! Consider the following code and
answer the questions in the table below.
#include <iostream>
template <typename T, int N=10>
class Array {
private:
T array[N+1];
public:
Array() {
for(int i=0; i<N+1; i++) array[i] =
0;
}
T& operator [] (int index) {
if (index>N || index < 0)
return array[N];
else
return array[index];
}
template <typename S>
Array<T,N>& operator= (S &other) {
for(int i=0; i<N+1; i++)
array[i] =
other[i];
return *this;
}
};
template <typename T, typename...
15. Given the function, and the main functioning it Which of the following chess Code include ciostream> using namespace std; void functe int& intt : int main() int = 3; 4; cout cu evecende: func(u, v) cout< <"eye endl; // 16. What will be the output after the following int a, b, c, d: statements have been executed? b - 12: - 37 if (acb2 cout << "a <b" << endl; if (ab) cout << "a > " << endl;...