The following code fragment
int x, y =2, z, a;
x = ( y* = 2 ) + ( z = a = y )
printf ( "%d" , x );
A. | prints 8 |
B. | prints 6 |
C. | prints 6 or 8 depending on the compiler implementation |
D. | is syntactically wrong |
Answer : 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. |
|
Option: A Explanation : Explanation will come here. Explanation will come here. Explanation will come here. Explanation will come here. Explanation will come here. |