Loop in C MCQs 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

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

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

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

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

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