Home / C Programming / Control Structures :: Discussion

Discussion :: Control Structures

  1. What will be the output given program?

    #include<stdio.h>

    void main()

    {

    int i = -10;

    for(;i;printf("%d ", i++));

    }

  2. A.

     -10 to -1

    B.

     -10 to infinite

    C.

     -10 to 0

    D.

     Complier error

    View Answer

    Workspace

    Answer : Option A

    Explanation :

    for loop can be initialized outside of the loop. Since until -1 value of i remain a non-zero value and hence the condition is true up to -1. But when i is further increases its value becomes 0 and condition becomes false and loop stops there.

    Note:In C any non-zero value(positive or negative) evaluates to true and only zero value is evaluates to false.


Be The First To Comment