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);
}
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
C. 10 5 4 3
D. 10 5 3 4
E. 10 5 5 5
Answer: Option B
Solution(By Examveda Team)
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.Join The Discussion
Comments ( 2 )
Related Questions on Operators and Expressions
What does the ++ operator do in C when applied to a variable?
A. Decrements by 1
B. Adds 1
C. Doubles the value
D. Leaves it unchanged
y=z++ not executed means it will not be evaluated
I think typing mistake..1st condition is only (w) not a (w < x)...