Multiple choice

The output of the following code snippet is ___________ ( ) main( ) { int x=3,y,z; y=x=10; z=x<10; printf(n x=%d y=%d z=%d,x,y,z); }

  1. 10 10 10

  2. 10 10 0

  3. 3 10 10

  4. error in code

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In the statement y=x=10, assignment is right-associative so x becomes 10, then y becomes 10. The expression z=x<10 compares 10 with 10, which is false (0). The printf outputs x=10, y=10, z=0.