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 i=10;

    printf("i=%d", i);

    {

    int i=20;

    printf("i=%d", i);

    i++;

    printf("i=%d", i);

    }

    printf("i=%d", i);

    }

  2. A.

     10 10 11 11

    B.

     10 20 21 21

    C.

     10 20 21 10

    D.

     10 20 21 20

    View Answer

    Workspace

    Answer : Option C

    Explanation :

    The scope of second declaration of i is limited to the block in which it is defined. Outside of the block variable is not recognized.


Be The First To Comment