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 x=5; static int y=0; void myFunction(int a) { y=++a; } int main (int argc, const char * argv[]) { int i=0; myFunction(i); cout<<y<<" "<<x; }A . It prints: 0 5B . It...

January 16, 2024 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...

January 15, 2024 No Comments READ MORE +

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

What is the output of the program if character 4 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; case 3: throw 'a'; default: cout<<"No exception"; } }...

January 15, 2024 No Comments READ MORE +

Which of the following statements are correct?

Which of the following statements are correct?A . A function can be defined inside another functionB . A function may have any number of return statements each returning different values.C . A function can return floating point valueD . In a function two return statements should never occur.View AnswerAnswer: B,...

January 15, 2024 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;} };...

January 15, 2024 No Comments READ MORE +

What is the output of the program?

What is the output of the program? #include <iostream> #include <string> using namespace std; int main() { string s1="Wo"; string s2; s2 = s1; string s3; s3 = s2.append("rldHello"); cout << s3; return(0); }A . It prints: WorldHelloB . It prints: HelloWoC . It prints: WorldD . It prints: HelloView...

January 15, 2024 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...

January 15, 2024 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; #define DEF_A 0 int main(int argc, char *argv[]) { cout << DEF_A; return 0; }A . It prints: 1B . It prints: 0C . It prints: ?1D . Compilation errorView AnswerAnswer: B

January 14, 2024 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 main(int argc, char *argv[]) { char *s = "ABCDEF"; cout << s+2; return 0; }A . It prints: CDEFB . It prints: ABCDEFC . It prints: BCDEFD . None of theseView AnswerAnswer:...

January 14, 2024 No Comments READ MORE +

return x?

What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; int op(int x, int y) { return x?y; } int op(int x, float y) { return x+y; } int main() { int i=1, j=2, k, l; float f=0.23; k = op(i, j); l...

January 14, 2024 No Comments READ MORE +