Home » C Programming » Loops » Question
  1. Which of the following is the correct output for the program given below?
    #include <stidio.h>
    int main( )
    {
    int a = 1, b = 1;
    for (; b; printf ("%d %d\n", a, b))
    b = a++ <= 5;
    return 0;
    }
    1. 2 1
      3 1
      4 1
      5 1
      6 1
      7 0
    2. 2 1
      3 1
      4 1
      5 1
      6 1
    3. 2 1
      3 1
      4 1
      5 1
    4. 2 1
      3 1
      4 1
      5 1
      5 5
    5. 2 2
      3 3
      4 4
      5 5
Correct Option: A

This loop will break only when value of b = 0
so Output will be
2 1
3 1
4 1
5 1
6 1
7 0



Your comments will be displayed only after manual approval.