Home / C Programming / Control Structures :: Discussion

Discussion :: Control Structures

  1. What will be the output of the given program?

    #include<stdio.h>

    void main()

    {

    int a=11,b=5;

    if(a=5) b++;

    printf("%d %d", ++a, b++);

    }

  2. A.

     12 7

    B.

     5 6

    C.

     6 6

    D.

     6 7

    E.

     11 6

    View Answer

    Workspace

    Answer : Option C

    Explanation :

    Here if condition evaluates to true as a non-zero value i.e 5 is assigned to a.
    So the value of a = 5 and after increment value of b = 6.
    In printf statement due to pre-increment of a value of a printed will be 6 and due to post-increment of b value of b printed will be 6 and not 7.


Be The First To Comment