Break and Continue in C MCQs Exercise II

Ques 1 Break and Continue


What is output of the following code?


int main()
{
   int k;
   for(i=0;k<5;k++)
   {
      printf("%d",k);
      break;
      printf("Label 1");
   }
   printf("Label 2");
   return 0;
}

A 0 Label 1
B 0 Label 2
C 1 Label 1
D 1 Label 2

Ques 2 Break and Continue


What is output of the following code?


int main()
{
    int k;
    do{
      printf("%d",k);
      continue;
      i++;
    }while(k<=10);
    return 0;
 }
 

A 1 2 3 4 5 6 7 8
B 0 2 3 4 6 8 9 0
C Infinite loop
D 0

The given code contains an infinite loop because the continue statement is placed before the increment of the loop variable k. This means that the loop will keep printing the uninitialized value of k without making any progress.