Home / C Programming / Operators and Expressions :: Discussion

Discussion :: Operators and Expressions

  1. Find the output of the following program.

    #include

    void main()

    {

    int y=10;

    if(y++>9 && y++!=10 && y++>11)

    printf("%d", y);

    else

    printf("%d", y);

    }

  2. A.

     11

    B.

     12

    C.

     13

    D.

     14

    E.

     Compilation error

    View Answer

    Workspace

    Answer : Option C

    Explanation :

    All the three condition in if is true.
    if(y++>9 && y++!=10 && y++>11) such as
    1st condition : 10++ > 9 is true and value of y is increase by 1 i.e y =11
    2nd condition : 11++ != 10 is also ture and value of y is increase by 1 i.e y =12
    3rd condition : 12++ > 11 is also ture and value of y is increase by 1 i.e y =13
    Therefore if is excuted and print the value of y = 13


Be The First To Comment