What happens when you attempt to compile and run the following code?

What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; void fun(int); int main() { int a=0; fun(a); return 0; } void fun(int n) { if(n < 2) { fun(++n); cout << n; } }A . It prints: 21 B.It prints: 012 C.It...

July 11, 2023 No Comments READ MORE +

What is the output of the program given below?

What is the output of the program given below? #include <iostream> using namespace std; int main (int argc, const char * argv[]) { int i=10; { int i=0; cout<<i; } cout<<i; return 0; }A . 1010 B.100 C.010 D.None of theseView AnswerAnswer: C

July 11, 2023 No Comments READ MORE +

b?

Which code, inserted at line 8, generates the output "0102020"? #include <iostream> using namespace std; class Base { static int age; public: Base () {}; ~Base () {}; //insert code here void Print() { cout << age;} }; int Base::age=0; int main () { Base a,*b; b = new Base();...

July 10, 2023 No Comments READ MORE +

What is the output of the program if character 2 is supplied as input?

What is the output of the program if character 2 is supplied as input? #include <iostream> using namespace std; int main () { int c; cin >> c; try { switch (c) { case 1: throw 20; case 2: throw 5.2f; } } catch (int e) { cout << "int...

July 10, 2023 No Comments READ MORE +

What happens when you attempt to compile and run the following code?

What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; int op(int x, int y); int main() { float *pf; float f=0.9; pf=&f; cout << op(1, *pf); return 0; } int op(int x, int y) { return x*y; }A . It prints: 0...

July 10, 2023 No Comments READ MORE +

What is the output of the program?

What is the output of the program? #include <iostream> using namespace std; int main() { int tab[4]={10,20,30,40}; tab[1]=10; int *p; p=&tab[0]; cout<<*p; return 0; }A . It prints: 10 B.It prints: 20 C.It prints: 11 D.It prints: 30View AnswerAnswer: A

July 10, 2023 No Comments READ MORE +

What happens when you attempt to compile and run the following code?

What happens when you attempt to compile and run the following code? #include <iostream> #include <string> using namespace std; class A { int x; protected: int y; public: int z; }; class B : public A { string name; public: void set() { y = 2; z = 3; }...

July 10, 2023 No Comments READ MORE +

complex operator?

What happens when you attempt to compile and run the following code? #include <iostream> #include <string> using namespace std; class complex{ double re, im; public: complex() : re(1),im(0.4) {} complex operator?(complex &t); void Print() { cout << re << " " << im; } }; complex complex::operator? (complex &t){ complex...

July 9, 2023 No Comments READ MORE +

Which code, inserted at line 10, generates the output "Hello World"?

Which code, inserted at line 10, generates the output "Hello World"? #include <iostream> #include <string> using namespace std; string fun(string, string); int main() { string s="Hello"; string *ps; ps = &s; //insert code here return 0; } string fun(string s1, string s2) { return s1+s2; }A . cout << fun("...

July 9, 2023 No Comments READ MORE +

A(int x) { this?

What happens when you attempt to compile and run the following code? #include <iostream> #include <string> using namespace std; class A { public: int x; A() { x=0;} A(int x) { this?>x=x;} }; class B : private A { public: using A::x; B() { x=1;} B(int x) {this?>x = x;}...

July 8, 2023 No Comments READ MORE +