Classical

C Programming MCQ - Decision Making & Looping

16:  

 The following program fragment

if (a = 0) printf ("a is zero");
else printf ("a is not zero");


results in the printing of

A.

a is zero

B.

a is not zero

C.

nothing

D.

garbage

 
 

Option: B

Explanation :


17:  

The following program fragment 

if ( a = 7 )
printf (" a is seven ");
else
printf (" a is not seven ");


results in the printing of

A.

a is even

B.

a is not even

C.

nothing

D.

garbage

 
 

Option: A

Explanation :


18:  

The following loop 

   for ( putchar( 'c' ); putchar ( 'a' ); putchar ( ' r' )) 
   putchar ( 't' );


outputs

A.

a syntax error 

B.

cartrt

C.

catrat

D.

catratratratrat

 
 

Option: D

Explanation :


19:  

The following loop 

for( i=1, j=10; i<6; ++i, --j )
printf ("%d %d", i, j );


prints

A.

1 10 2 9 3 8 4 7 5 6 

B.

1 2 3 4 5 10 9 8 7 6 

C.

1 1 1 1 1 1 9 9 9 9 9 

D.

none of above

 
 

Option: A

Explanation :


20:  

The following Program

main() 
{
int i = 5;
if (i == 5) return;
else printf (" is not five");
printf("over");
}


results in

A.

a syntax error

B.

an execution error

C.

printing of over

D.

execution termination, without printing anything

 
 

Option: D

Explanation :




Suggest an improvement