What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;class complex{double re;double im;public:complex() : re(0),im(0) {}complex(double x) { re=x,im=x;};complex(double x,double y) { re=x,im=y;}void print() { cout << re << " " << im;}};int main(){complex c1(1,2);c1.print();return 0;}
Answer(s): C
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;}
What happens when you attempt to compile and run the following code?#include <iostream>#include <string>using namespace std;class A {int x;protected:int y;public:int z;A() { x=1; y=2; z=3; }};class B : public A {string z;public:void set() {y = 4;z = "John";}void Print() {cout << y << z;}};int main () {B b;
Answer(s): A
What happens when you attempt to compile and run the following code?#include <iostream>#include <string>using namespace std;const int size = 3;class A {public:string name;A() { name = "Bob";}A(string s) { name = s;}A(A &a) { name = a.name;}};class B : public A {public:B() { }B(string s) : A(s) { }void Print() {cout << name;}};int main () {B b1("Alan");b1.Print();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;}{i=5;cout << i;}cout<<i;return 0;}
Post your Comments and Discuss C++ Institute CPA-21-02 exam prep with other Community members: