C Programming MCQ - I/O Operations

36:  

What is the output of the following 'C' program?
main()
{
int a[5]={2,3};
printf("\n%d%d%d",a[2],a[3],a[4]);
}

A.

Garbage Values

B.

Error

C.

3 2 2

D.

0 0 0

 
 

Option: D

Explanation :

Click on Discuss to view users comments.

Write your comments here:



37:  

What is the output of the following 'C' program? main() { printf("%f",sqrt(36.0)); }

A.

6.0

B.

6

C.

6.000000

D.

None of these

 
 

Option: C

Explanation :

Click on Discuss to view users comments.

Write your comments here:



38:   If following variables are set to the values as shown below, then what is the value of the expression following it? answer=2; marks=10; !((answer2))
A. -1
B. 0
C. -1
D. Error
 
 

Option: B

Explanation :

Click on Discuss to view users comments.

Write your comments here:



39:   Consider following statements:
putchar(getchar());
putchar(getchar());
If
a
b
is the input, then output will be
A. An error message
B. this can't be the input
C. a, b
D. Undefined
 
 

Option: B

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

Click on Discuss to view users comments.

Write your comments here:



40:   The program fragment
int i =263;
purchar(i);
prints
A. 263
B. ASCII equivalent of 263
C. Rings the bell
D. undefined
 
 

Option: C

Explanation :
263 in binary form is 100000111. If one tries to print an integer as character, only the last 8 bits will be considered-the rest chopped off. So, in this case the ASCII value of 00000111 (i.e.,decimal 7) will be printed. Look in the ASCII table. It is ringing a bell!

Click on Discuss to view users comments.

Write your comments here: