Halloween Special - Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: sntaclus

What happens if character 3 is entered as input?

#include

using namespace std;

class A {

public:

int i;

};

int main () {

int c;

A obj;

obj.i = 5;

cin >> c;

try

{

switch (c)

{

case A. throw 20;

case B. throw 5.2f;

case C. throw obj;

default: cout<<"No exception";

}

}

catch (int e)

{ cout << "int exception. Exception Nr. " << e; }

catch (A e)

{ cout << "object exception. Exception Nr. " << e.i; }

catch (...)

{ cout << "An exception occurred."; }

return 0;

}

A.

It prints: object exception. Exception Nr. 5

B.

It prints: int exception. Exception Nr.

C.

It prints: An exception occurred

D.

It prints: No exception

What is the output of the program?

#include

#include

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: World

What happens when you attempt to compile and run the following code?

#include

using namespace std;

int main()

{

int x=0;

int *ptr;

ptr = &x;

cout<

return 0;

}

A.

It prints: 0 0

B.

It prints address of ptr

C.

It prints: 1

D.

It prints: 2

What happens when you attempt to compile and run the following code?

#include

using namespace std;

class A {

public:

virtual void Print()=0;

};

class B:public A {

public:

virtual void Print() { cout<< "B"; }

};

class C:public A {

public:

virtual void Print() { cout<< "C"; }

};

int main()

{

B ob2;

C ob3;

A *obj;

obj = &ob2;

obj?>Print();

obj = &ob3;

obj?>Print();

}

A.

It prints: BC

B.

It prints: CB

C.

It prints: CC

D.

It prints: BB

What happens when you attempt to compile and run the following code?

#include

using namespace std;

class Test {

float i,j;

};

class Add {

public:

int x,y;

Add (int a=3, int b=3) { x=a; y=b; }

int result() { return x+y;}

};

int main () {

Test test;

Add * padd;

padd = &test;

cout << padd?>result();

return 0;

}

A.

It prints: 6

B.

It prints: 9

C.

Compilation error

D.

It prints: 33

What happens when you attempt to compile and run the following code?

#include

using namespace std;

int main(){

int i = 1;

for(i=10; i>-1; i/=2) {

if(!i)

break;

}

cout << i;

return 0;

}

A.

It prints: 0

B.

It prints: 1

C.

It prints: -1

D.

Compilation error

What happens when you attempt to compile and run the following code?

#include

using namespace std;

int main()

{

float x=3.5,y=1.6;

int i,j=2;

i = x + j + y;

cout << i;

return 0;

}

A.

It prints: 7

B.

It prints: 6

C.

It prints: 7,1

D.

Compilation error

What happens when you attempt to compile and run the following code?

#include

using namespace std;

void fun(int);

int main()

{

int a=0;

fun(a);

return 0;

}

void fun(int n)

{

if(n < 2)

{

fun(++n);

cout << n;

}

}

A.

It prints: 21

B.

It prints: 012

C.

It prints: 0

D.

None of these

What happens when you attempt to compile and run the following code?

#include

using namespace std;

int main()

{

const int x=0;

const int *ptr;

ptr = &x;

cout<<*ptr;

return 0;

}

A.

It prints: 0

B.

It prints address of x

C.

It prints: 1

D.

Compilation error

What is the output of the program?

#include

#include

using namespace std;

struct Person {

int age;

};

class First

{

Person *person;

public:

First() {person = new Person;

person?>age = 20;

}

void Print(){

cout << person?>age;

}

};

int main()

{

First t[2];

for (int i=0; i<2; i++)

t[i].Print();

}

A.

It prints: 10

B.

It prints: 2020

C.

It prints: 22

D.

It prints: 00