Control Structures MCQs
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 118hard
What will be the output of the following C code?
#include <stdio.h>
void main()
{
int i = 0;
for (i = 0;i < 5; i++)
if (i < 4)
{
printf("Hello");
break;
}
}Question 119medium
Which of the following is an invalid if-else statement?
Question 120hard
What will be the output of the following C code?
#include <stdio.h>
int main()
{
short i;
for (i = 1; i >= 0; i++)
printf("%d\n", i);
}Advertisement
Question 121hard
What will be the output of the following C code?
#include <stdio.h>
int main()
{
int i = 0, j = 0;
while (i < 2)
{
l1: i++;
while (j < 3)
{
printf("loop\n");
goto l1;
}
}
}Question 122easy
What will be the correct syntax for running two variable for loop simultaneously?
Question 123hard
Which for loop has range of similar indexes of 'i' used in for (i = 0;i < n; i++)?
Advertisement
Question 124hard
What will be the output of the following C code?
#include <stdio.h>
int main()
{
do
printf("In while loop ");
while (0);
printf("After loop\n");
}Question 125hard
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 126hard
What will be the output of the following C code?
#include <stdio.h>
int main()
{
switch (printf("Do"))
{
case 1:
printf("First\n");
break;
case 2:
printf("Second\n");
break;
default:
printf("Default\n");
break;
}
}