Control Structures MCQs

155 questionsC-ProgramPage 8 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 64hard
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    int *p = NULL;
    for (foo(); p; p = 0)
        printf("In for loop\n");
        printf("After loop\n");
}
Question 65hard
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    printf("%d ", 1);
    goto l1;
    printf("%d ", 2);
    l1:goto l2;
    printf("%d ", 3);
    l2:printf("%d ", 4);
}
Question 66medium
The keyword 'break' cannot be simply used within . . . . . . . .
Advertisement
Question 67hard
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    int x = 0;
    if (x == 1)
        if (x == 0)
            printf("inside if\n");
        else
            printf("inside else if\n");
    else
        printf("inside else\n");
}
Question 68hard
What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input)
#include <stdio.h>
void main()
{
    char *ch;
    printf("enter a value between 1 to 3:");
    scanf("%s", ch);
    switch (ch)
    {
       case "1":
          printf("1");
          break;
       case "2":
          printf("2");
          break;
    }
}
Question 69hard
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    int i = 0, j = 0;
    l1: while (i < 2)
        {
            i++;
            while (j < 3)
            {
                printf("loop\n");
                goto l1;
            }
        }
}
Advertisement
Question 70hard
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    int x = 0;
    if (x == 0)
        printf("true, ");
    else if (x = 10)
        printf("false, ");
    printf("%d\n", x);
}
Question 71hard
What will be the output of the following C code?
#include <stdio.h>
int main()
{
   int i = 0;
   do
   {
       i++;
       if (i == 2)
           continue;
           printf("In while loop ");
   } while (i < 2);
   printf("%d\n", i);
}
Question 72hard
What will be the output of the following C code?
#include <stdio.h>
void main()
{
    int k;
    for (k = -3; k < -5; k++)
        printf("Hello");
}