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

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

#include

using namespace std;

int main(){

int i, j;

for(i = 0, j = 1; j < 2, i < 4; i++, j++);

cout << i << " " << j;

return 0;

}

A.

It prints: 4 5

B.

It prints: 2 3

C.

It prints: 3 2

D.

It prints: 4 3

What is the output of the program if character 4 is supplied as input?

#include

using namespace std;

int main () {

int c;

cin >> c;

try

{

switch (c)

{

case 1:

throw 20;

case 2:

throw 5.2f;

case 3:

throw 'a';

default:

cout<<"No exception";

}

}

catch (int e)

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

catch (float e)

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

catch (...)

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

return 0;

}

A.

It prints: float exception. Exception Nr.

B.

It prints: int exception. Exception Nr.

C.

It prints: An exception occurred

D.

It prints: No exception

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

#include

using namespace std;

int main()

{

const char *s;

char str[] = "Hello ";

s = str;

while(*s) {

cout << *++s;

*s++;

}

return 0;

}

A.

It will print:"el "

B.

The code will not compile.

C.

It will print:"Hello "

D.

It will print garbage value

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

#include

#include

using namespace std;

class myClass : public exception

{

virtual const char* what() const throw()

{

return "My exception.";

}

} obj;

int main () {

try

{

throw obj;

}

catch (exception& e)

{

cout << e.what() << endl;

}

return 0;

}

A.

It prints: My exception.

B.

It prints: 0

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 (int argc, const char * argv[])

{

int a = 30, b = 1, c = 5, i=10;

i = b < a < c;

cout << i;

return 0;

}

A.

compilation fails

B.

It prints: 10

C.

It prints: 0

D.

It prints: 1

What is the output of the program if characters 't', 'e', 's' and 't' enter are supplied as input?

#include

#include

using namespace std;

int main()

{

string s;

getline( cin, s );

cout << s << " " << s.length();

return( 0 );

}

A.

It prints: test 4

B.

It prints: test

C.

It prints: test 5

D.

It prints: 4

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

#include

using namespace std;

int x=5;

static int y;

int i=0;

void static myFunction()

{

y=x++ + ++i;

}

int main (int argc, const char * argv[])

{

x++;

myFunction();

cout<

}

A.

Compilation fails

B.

It prints: 5 5 0

C.

It prints: 7 7 1

D.

It prints: 6 5 1

Point out an error in the program.

#include

using namespace std;

int main()

{

const int x=1;

int const *y=&x;

cout<<*y;

return 0;

}

A.

No error

B.

Error: unknown pointer conversion

C.

cannot convert from 'const int *' to 'int *const'

D.

Compilation error

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

#include

using namespace std;

int x=5;

static int y=0;

void myFunction(int a)

{

y=++a;

}

int main (int argc, const char * argv[])

{

int i=0;

myFunction(i);

cout<

}

A.

It prints: 0 5

B.

It prints: 5 1

C.

It prints: 1 5

D.

It prints: 5 0

Which of the following is a logical operator?

A.

&

B.

&&

C.

||

D.

!