ExamVeda
Login
Home
Operators and Expressions
?

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);
}

Answer & Solution
Correct Answer: Option B
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.
Examveda
Question posted by Examveda
Community

Join the Discussion

2 Comments
Shraddha Baviskar
Shraddha Baviskar 8 years ago
y=z++ not executed means it will not be evaluated
Shani Ravaliya
Shani Ravaliya 9 years ago
I think typing mistake..1st condition is only (w) not a (w < x)...