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

Only first and 2nd loop will be executing here
So output will be.
4 3 2 1 0 -1
4 3 2 1 0 -1



Your comments will be displayed only after manual approval.