What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; int main() { float i = 1.0 / 2 * 2 / 1 * 2 / 4 * 4 / 2; cout << i; return 0; }
Answer(s): B
What is the output of the program? #include <iostream> #include <string> using namespace std; class First { string name; public: First() { name = "Alan"; } void Print(){ cout << name; } }; int main() { First ob1,*ob2; ob2 = new First(); ob1.Print(); ob2?>Print(); }
What will the variable "age" be in class B? class A { int x; protected: int y; public: int age; }; class B : protected A { string name; public: void Print() { cout << name << age; } };
Answer(s): C
What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; int main() { const int x=20; const int *ptr; ptr = &x; *ptr = 10; cout<<*ptr; return 0; }
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; } { int i=5; cout << i; } cout<<i; 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.