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(){Second t[2];for (int i=0; i<2; i++)t[i].Print();}
Answer(s): C
What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;void fun(int*);int main(){int *x;int i=2;x=&i;fun(x);cout<<i;return 0;}void fun(int *i){*i = *i * *i;}
Answer(s): B
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.3) {}complex(double n) { re=n,im=n;};complex(int m,int n) { re=m,im=n;}complex operator+(complex &t);void Print() { cout << re << " " << im; }};complex complex::operator+ (complex &t){complex temp;temp.re = this?>re + t.re;temp.im = this?>im + t.im;return temp;}int main(){complex c1(1),c2(2),c3;c3 = c1 + c2;c3.Print();}
What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;int main(){int i = 0;do {i++;if (i==3)break;cout<<i;}while(i < 5);return 0;}
Answer(s): A
What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;int compare(int, int);int main(){int x = compare(10, 20);cout << x;return 0;}int compare(int i, int j){return i<j;}
Post your Comments and Discuss C++ Institute CPA-21-02 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-21-02 content, but please register or login to continue.