Examveda
Examveda

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

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.

This Question Belongs to C Program >> Operators And Expressions

Join The Discussion

Comments ( 2 )

  1. Shraddha Baviskar
    Shraddha Baviskar :
    6 years ago

    y=z++ not executed means it will not be evaluated

  2. Shani Ravaliya
    Shani Ravaliya :
    7 years ago

    I think typing mistake..1st condition is only (w) not a (w < x)...

Related Questions on Operators and Expressions