Control Structures MCQs

155 questionsC-ProgramPage 16 of 18

Practice free Control Structures multiple-choice questions with instant answer feedback and step-by-step solutions. Click an option to check yourself, reveal the full explanation, and work through all 155 questions — no login required.

Question 136hard
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    int i = 0;
    for (; ; ;)
        printf("In for loop\n");
        printf("After loop\n");
}
Question 137medium
Which of the following cannot be used as LHS of the expression in for (exp1;exp2; exp3)?
Question 138hard
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    int i = 0, j = 0;
    for (i; i < 2; i++){
        for (j = 0; j < 3; j++)
        {
            printf("1\n");
            break;
        }
        printf("2\n");
    }
    printf("after loop\n");
}
Advertisement
Question 139hard
Comment on the output of the following C code.
#include <stdio.h>
int main()
{
    int a = 1;
    switch (a)
    case 1:
        printf("%d", a);
    case 2:
        printf("%d", a);
    case 3:
        printf("%d", a);
    default:
        printf("%d", a);
}
Question 140hard
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    int a = 1, b = 1;
    switch (a)
    {
       case a*b:
          printf("yes ");
       case a-b:
          printf("no\n");
          break;
    }
}
Question 141hard
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    printf("%d ", 1);
    l1:l2:
    printf("%d ", 2);
    printf("%d\n", 3);
}
Advertisement
Question 142hard
What will be the output of the following C code? (Assuming that we have entered the value 2 in the standard input)
#include <stdio.h>
void main()
{
    int ch;
    printf("enter a value between 1 to 2:");
    scanf("%d", &ch);
    switch (ch)
    {
       case 1:
          printf("1\n");
          break;
          printf("Hi");
       default:
          printf("2\n");
    }
}
Question 143hard
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    printf("%d ", 1);
    goto l1;
    printf("%d ", 2);
}
void foo()
{
    l1 : printf("3 ", 3);
}
Question 144hard
What will be the output of the following C code?
#include <stdio.h>
void main()
{
    int i = 0, j = 0;
    for (i = 0;i < 5; i++)
    {
        for (j = 0;j < 4; j++)
        {
            if (i > 1)
                break;
        }
        printf("Hi \n");
    }
}