Click to Get updated NTA UGC NET CS Test Series           Study Material for UGC NET Computer Science- 2019

# C Programming MCQ - I/O Operations

11:

The following program fragment
int k = -7;
printf(“%d", 0 < lk);

 A. prints 0 B. prints a non-zero value C. is illegal D. prints an unpredictable value Answer Report Discuss Option: A Explanation : k = -7. So, if 'k' is used as a Boolean variable, it will be treated as a true condition. So. ! k will be false i.e., 0. So, 0 < ? !k is actually 0 < 0. which is false. So. 0 will be printed. Click on Discuss to view users comments. Write your comments here:
12:

The following program fragment

int a = 4, b = 6;
printf (" %d ", a == b);

 A. outputs an error message B. prints 0 C. prints 1 D. none of the above Answer Report Discuss Option: B Explanation : Click on Discuss to view users comments. Write your comments here:
13:

The following program fragment

int a = 4, b = 6;
printf (" %d ", a != b) ;

 A. outputs an error message B. prints 0 C. prints 1 D. none of these Answer Report Discuss Option: C Explanation : Click on Discuss to view users comments. Write your comments here:
14:

The following program fragment

int a = 4, b = 6;
printf ("%d", a = b) ;

 A. outputs an error message B. prints 0 C. prints 1 D. 6 Answer Report Discuss Option: D Explanation : Here in this program, the output will be '6' . The program assigns b's value to a. So, a becomes 6. While, the "%d" will display value of the second variable in the printf statement which is "b=6" Click on Discuss to view users comments. suman sharma said: (7:23pm on Wednesday 18th September 2013) output of this program is=6;because we assign the value of b to a, we have b=6 then automatically value a=6; Write your comments here:
15:

The following program fragment

int i = 107, x = 5;
printf  (( x  > 7) ? " %d " : "%c", i ) ;

results in

 A. an execution error B. a syntax error C. printing of k D. none of the above Answer Report Discuss Option: C Explanation : Since x > 7 is false, the ternary operator?: returns "%c". So, print f ( "%c " ,  i) will be executed. So, the ASCII character corresponding to 107, i.e., ' k ' will be printed. Click on Discuss to view users comments. Write your comments here:

X