Programming in C - I/O Operations

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

  • 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.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


12. The following program fragment
int a = 4, b = 6;
printf (" %d ", a == b);

Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


13. The following program fragment
int a = 4, b = 6;
printf (" %d ", a != b) ;

Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


14. The following program fragment
int a = 4, b = 6;
printf ("%d", a = b) ;

  • 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"
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


15. The following program fragment
int i = 107, x = 5;
printf (( x > 7) ? " %d " : "%c", i ) ;
results in

  • 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.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *