C Programming MCQ

1:

Consider the following program fragment

if (a>b)
   printf("a>b");
else
   printf("else part");
   printf("a<=b");


a<=b will be printed if

A.

a>b

B.

a<b

C.

a==b

D.

Both (b) and (c)

 

Answer : D

Explanation :

The else clause has no brackets i.e., { and }. This means the else clause is made up of only one statement. So, printf( " a < = b" ) will be executed anyway, i.e. if a > b or a <= b. Hence the answer.

Write your comments here:


Report Error
 

Option: A

Explanation : Explanation will come here. Explanation will come here. Explanation will come here. Explanation will come here. Explanation will come here.