Home / C Programming / Control Structures :: Discussion

Discussion :: Control Structures

  1. What will be the value of i and j after execution of following program?

    #include<stdio.h>

    void main()

    {

    int i, j;

    for(i=0,j=0;i<10,j<20;i++,j++){

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

    }

    }

  2. A.

     10 10

    B.

     10 20

    C.

     20 20

    D.

     Run time error

    View Answer

    Workspace

    Answer : Option C

    Explanation :

    comma operator is executed from left to right so until j<20 for loop statement is true, so both i and j are incremented.
    So, i = 20 and j = 20.


Be The First To Comment