Classical

C Programming MCQ - Decision Making & Looping

36:  

The body of the following for loop

 for( putchar( 'a' ); putchar (0); putchar (' c ') ) putchar ( 'b') ;

will be executed

A.

0 times

B.

1 times

C.

infinitely many times

D.

will not be executed because of syntax error

 
 

Option: A

Explanation :

The condition is putchar (0) . This returns a value 0 which is a false condition. So, the loop will not be executed even once. 


37:  

 The following statement

if (a > b)
if (c > b)
printf("one");
else
if (c == a) printf('two');
else printf("three");
else printf("four");

A.

 results in a syntax error

B.

prints four in c <= b

C.

prints two if c <= h

D.

prints four in a <= b

 
 

Option: D

Explanation :


38:  

Code in the previous question can never print

A.

one 

B.

two

C.

three

D.

four

 
 

Option: B

Explanation :


39:  

 The following program fragment

int x = 4, y = x, i;
for (i = 1; i < 4; ++i)
x += x;


outputs an integer that is same as

A.

8 * y

B.

y * (1 + 2+ 3 + 4) 

C.

y * 4

D.

Y * Y

 
 

Option: A

Explanation :


40:  

 Using goto inside for loop is equivalent to using

A.

continue

B.

break

C.

return

D.

none of the above

 
 

Option: D

Explanation :




Suggest an improvement