Home / C Programming / Operators and Expressions :: Discussion

Discussion :: Operators and Expressions

  1. 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);

    }

  2. 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

    View Answer

    Workspace

    Answer : Option B

    Explanation :

    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.


Be The First To Comment