Loop in C MCQs with Answer Exercise I


Ques 1 Loop


What is the output of the following code?

int main()
{
    int x=3,y=2;
    while(x+y-1)
    {
        printf("%d",x=x+y);
    }
    return 0;
}

  a) 1 5 6 9 11
  b) Error
  c) Infinite Loop
  d) 2 4 6 8 10


c is the correct option




Ques 2 Loop


What is the output of the following code?

int main()
{
    int i,j=0;
    for(i=0;i<5;++i,i++,j++)
    {
        printf("%d %d ",i,j);
    }
     return 0;
}

  a) 0 1 3 2 4 5
  b) 0 1 2 3 5 6
  c) 0 0 2 1 4 2
  d) 1 3 4 1 4 6


c is the correct option




Ques 3 Loop


What is the output of the following code?

int main()
{
     int i;
     for(i=0;i<=4,i++);
         printf("%d",i);
     return 0;
}

  a) 0 1 2 3 4
  b) 0 1 2 3 5
  c) 1 2 3 4 5
  d) None of these


d is the correct option




Ques 4 Loop


What is the output of the following code?

#include<sdtio.h>
int main()
{
       while()
       {
             printf("SmallCode!");
       }  
}

  a) SmallCode!
  b) Infinite Loop
  c) Error
  d) None of these


c is the correct option




Ques 5 Loop


What is the output of the following code?

#include<sdtio.h>
int main()
{
       int a=6,b=2;
       while(a<=6 && b<=4)
       {
             printf("SmallCode!");
       }  
}

  a) SmallCode!
  b) Infinite Loop
  c) SmallCode!SmallCode!SmallCode!
  d) compilation error


b is the correct option




Ques 6 Loop


Which of the following keyword are used for iteration in C Programming?
  a) for
  b) while
  c) do while
  d) All of these


d is the correct option