CP I/O Q3

0. The following code fragment
int x, y =2, z, a;
x = ( y* = 2 ) + ( z = a = y )
printf ( "%d" , x );

  • Option : C
  • Explanation :
    y * = 2 means y = y * 2 i.e. y = 4, in this problem.
    So, the expression is equivalent to x = 4 + 4, which is 8.
    So, 8 will be printed.
    However, the order in which the operands are evaluated is implementation-dependent.
    If the right operand is evaluated first, the result will be 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 *