What will happen when you attempt to compile and run the following code?
What will happen when you attempt to compile and run the following code? #include <iostream> using namespace std; int getValue(); int main() { const int x = getValue(); cout<<x; return 0; } int getValue() { return 5; }A . It will print 0 B.The code will not compile. C.It will...
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: 1 B.It prints: 2 C.It prints: 4 D.It prints: 0View AnswerAnswer: C
obj?
What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; class A { public: void Print(){ cout<<"A"; } }; class B:public A { public: virtual void Print(){ cout<< "B"; } }; class C:public B { public: void Print(){ cout<< "C"; } }; int...
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"; } }...
What will the variable "age" be in class B?
What will the variable "age" be in class B? class A { int x; protected: int y; public: int age; A () { age=5; }; }; class B : public A { string name; public: B () { name="Bob"; }; void Print() { cout << name << age; } };A...
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 fun(int x) { return 2*x; } int main(){ int i; i = fun(1) & fun(0); cout << i; return 0; }A . It prints: 0 B.It prints: 1 C.It prints: -1 D.Compilation...
What will the variable "age" be in class B?
What will the variable "age" be in class B? class A { int x; protected: int y; public: int age; }; class B : private A { string name; public: void Print() { cout << name << age; } };A . public B.private C.protected D.None of theseView AnswerAnswer: B
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" , "World" }; for (int i=0; i<2; i++) { cout << s1[i]; } return( 0 ); }A . It prints: HelloWorld B.It prints: Hello C.It prints: WorldHello D.It prints: WorldView...
return s(n?
What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; int s(int n); int main() { int a; a = 3; cout << s(a); return 0; } int s(int n) { if(n == 0) return 1; return s(n?1)*n; }A . It prints: 4...
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 fun(int x) { return x<<2; } int main(){ int i; i = fun(1) / 2; cout << i; return 0; }A . It prints: 0 B.It prints: 1 C.It prints: 2 D.It...