Question discussion

What will be the output of the following C program?

359059Medium DSSSB TGT Computer Science 0 replies 0 views
0
What will be the output of the following C program?
#include <stdio.h>
int main()
{
    int i = 1;
    do
    {
        printf("%d ", i);
        i++;
    } while (i <= 5);
    return 0;
}
  • AInfinite Loop
  • B1 2 3 4 5 6
  • C1 2 3 4 5
  • D2 3 4 5 6
Correct answer: C

Explanation

The do-while loop prints i from 1 up to 5 and stops when i becomes 6. So the output is "1 2 3 4 5".

Discussion 0

Nobody has replied yet. Start the discussion!