C Language MCQ’S : Operators and Expressions Set 1

Which of the following comments regarding the reading of a string, using scanf(with optional) and gets is true?

A. Both can be used interchangeably
B. Scanf is delimited by end of line, while gets is not
C. Scanf is delimited by blank, while gets is not
D. All of above


The minimum number of temporary variables needed to swap the contents of two variables is

A. 1
B. 2
C. 3
D. 0


If s and b are integers then purpose of the following program fragment is to

b = s + b ;
s = b – s ;
b = b – s ;

A. transfer the contents of s to b
B. transfer the content of b to s
C. exchange (swap) the contents of s and b
D. negate the contents of s and b


Output the following statement will be
printf ( “%d” , printf ( “hello” ) ):

A. results in a syntax error
B. outputs hello5
C. outputs garbage
D. prints tim and terminates abruptly


If a b c 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


Visitor Counter