Vidyalelo
C Programming · Q52

Operators and Expressions

Programming · C Programming · question 52

Q52

Identify the correct output of the following code: void main() int w=10, x=5, y=3, z=3; if( (w < x ) && (y=z++) ) printf("%d %d %d %d", w, x, y, z); else printf("%d %d %d %d", w, x, y, z);

A.
10 5 4 4
B.
10 5 3 3
Answer
C.
10 5 4 3
D.
10 5 3 4
E.
10 5 5 5

Answer: Option B

Solution

Answer: Option B
Solution:
As the first condition ( w < x) is false and the logical operator && is used, the entire relation becomes false and the second part ( y = z++) is not executed.