Classical

C Programming MCQ - Constant Variables & Data Types

31:  

If integer needs two bytes of storage, then maximum value of a signed integer is

A.

 216 -1

B.

 215 -1

C.

216

D.

215

 
 

Option: B

Explanation :

In signed magnitude form, one bit is dedicated to store the sign.  (e.g.. 1 for negative and 0. otherwise). Only the remaining 15 bits arc available to store the magnitude. Hence the answer.


32:  

 printf ( "%d" , printf ( "tim" ) ):

A.

results in a syntax error

B.

outputs tim3

C.

outputs garbage

D.

prints tim and terminates abruptly

 
 

Option: B

Explanation :

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).


33:  

 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

 
 

Option: 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.


34:  

Consider the statements
putchar ( getchar ( ));
putchar(getchar( ));
if
a
b
is the input, the output will be

A.

an error message

B.

this can't be the input

C.

ab

D.

a   b

 
 

Option: B

Explanation :

The input is actually a \ n b. Since we are reading only two charactcrs, only a and \ will be read and printed.


35:  

Literal means

A.

a string

B.

a string constant

C.

a character

D.

an alphabet

 
 

Option: B

Explanation :




Suggest an improvement