Which code, inserted at line 14, generates the output "3.14 10"? #include <iostream> using namespace std; namespace myNamespace1 { int x = 5; int y = 10; } namespace myNamespace2 { float x = 3.14; float y = 1.5; } int main () { //insert code here cout << x << " " << y; return 0; }
Answer(s): D
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 ); }
Answer(s): A
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(); a.Print(); a.setAge(10); a.Print(); b?>setAge(); a.Print(); b?>Print(); return 0; }
What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; class First { public: void Print(){ cout<<"from First";} }; class Second { public: void Print(){ cout<< "from Second";} }; int main() { First FirstObject; FirstObject.Print(); Second SecondObject; SecondObject.Print(); }
Answer(s): C
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; }
Post your Comments and Discuss C++ Institute CPA exam prep with other Community members:
Our website is free, but we have to fight against AI bots and content theft. We're sorry for the inconvenience caused by these security measures. You can access the rest of the CPA content, but please register or login to continue.