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 x=2, *y; y = &x; cout << *y + x; return 0; }A . It prints: 1B . It prints: 2C . It prints: 4D . It prints: 0View...
What happens if character 3 is entered as input?
What happens if character 3 is entered as input? #include <iostream> using namespace std; class A { public: int i; }; int main () { int c; A obj; obj.i = 5; cin >> c; try { switch (c) { case A. throw 20; case B. throw 5.2f; case C....
obj?
Which code, inserted at line 5, generates the output "ABC"? #include <iostream> using namespace std; class A { public: //insert code here }; class B:public A { public: void Print(){ cout<< "B"; } }; class C:public B { public: void Print(){ cout<< "C"; } }; int main() { A ob1;...
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 i = 1; if (i==1) { cout << i; } else { cout << i-1; } return 0; }A . It prints: 0B . It prints: 1C . It prints:...
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 #define DEF_B DEF_A+1 #define DEF_C DEF_B+1 int main(int argc, char *argv[]) { cout << DEF_C; return 0; }A . It prints: 2B . It prints: 10C . It prints: 0D...
A ob1; obj = &ob1; obj?
What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; class A { public: virtual void Print(){ cout<<"A";} }; class B:public A { public: void Print(){ cout<< "B";} }; int main() { A *obj; A ob1; obj = &ob1; obj?>Print(); B ob2; obj...
Which code, inserted at line 15, generates the output "5 Bob"?
Which code, inserted at line 15, generates the output "5 Bob"? #include <iostream> #include <string> using namespace std; class B; class A { int age; public: A () { age=5; }; friend void Print(A &ob, B &so); }; class B { string name; public: B () { name="Bob"; }; //insert...
How could you pass arguments to functions?
How could you pass arguments to functions?A . by valueB . by referenceC . by pointerD . by voidView AnswerAnswer: A, B, C
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 = "Hello", s2 = "World"; s2 = s1 + s2; cout << s2; return 0; }A . It prints: HelloB . It prints: HelloWorldC . It prints: WorldHelloD . It...
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 *i; i = new int; *i = 1.0 / 2 * 2 / 1 * 2 / 4 * 4; cout << *i; return 0; }A . It prints: 0B...