C Programming MCQ

1:

 If abc is the input, then the following program fragment
                       char x, y, z ;
                       printf ("% d" , scanf ("%c%c%c" , &x , &y , &z )) ;

results in

A.

a syntax error

B.

a fatal error

C.

segmentation violation

D.

printing of 3

 

Answer : D

Explanation :

take refrence from below.
Any function (including main ( ) ) , returns a value to the calling environment. In the case of printf , it is the number of characters it printed. So. the output will be tim3 (since it printed the three characters a, b, c).
The scanf function returns the number of successful matches. i.e., 3 in this case.

HIFZURRAHAMAN said: (12:08am on Tuesday 27th December 2016)
after running the program the output is obtained: -1

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.