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. 

Click on Discuss to view users comments.

Write your comments here:



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 :

Click on Discuss to view users comments.

Write your comments here:



38:  

Code in the previous question can never print

A.

one 

B.

two

C.

three

D.

four

 
 

Option: B

Explanation :

Click on Discuss to view users comments.

kambosac said: (6:15pm on Tuesday 8th August 2017)
why it is so

Write your comments here:



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 :

Click on Discuss to view users comments.

Write your comments here:



40:  

 Using goto inside for loop is equivalent to using

A.

continue

B.

break

C.

return

D.

none of the above

 
 

Option: D

Explanation :

Click on Discuss to view users comments.

Write your comments here: