You are on page 1of 2

For what values of the expression is an if-statement block not executed?

A. 0 and all negative values


B. 0 and -1
C. 0
D. 0, all negative values, all positive values except 
ANSWER; C
What will be the ouput ?
int x=20;
if(++x%2==0)
cout<<”yes”;
else
cout<<”No”;
A. Yes
B. NO
ANSWER: B
What will be the ouput ?
int x=20;
if(x++%2==0)
cout<<”yes”;
else
cout<<”No”;
A. Yes
B. NO
ANSWER: A
What should be printed on screen?
int x = 5;
if(x++ <= 5)
cout<<"Five"<<endl;
else
if(++x <= 6)
cout<<"Six"<<endl;
return 0;

A. FiveSix
B. Five
C. Six
D. None of these
ANSWER: B
What does the following code fragment write to the monitor?

int sum = 14;


if ( sum < 20 )
cout<<"Under ";
else
cout<< “Over ";
cout<<”the limit”;

A. Under
B. Over
C. Under the limit
D. Over the limit
ANSWER: C
What does the following code fragment write to the monitor?

int sum = 14;


if ( sum > 20 )
cout<<"Under ";
else
cout<< “Over ";
cout<<”the limit”;

A. Under
B. Over
C. Under the limit
D. Over the limit
ANSWER: D
What should be the output of below program?
int main()
{ int a = 1;
switch(a) {
case 1: cout<<"One";
case 2: cout<<"Two";
case 3: cout<<"Three";
default: cout<<"Default";
} return 0;}

A. One
B. Compilation Error
C. Default
D. OneTwoThree Default

ANSWER: D

You might also like