21. 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;
}
}
}
#include <stdio.h>
int main()
{
int i = 0, j = 0;
while (i < 2)
{
l1: i++;
while (j < 3)
{
printf("loop\n");
goto l1;
}
}
}
22. What will be the correct syntax for running two variable for loop simultaneously?
23. Which for loop has range of similar indexes of 'i' used in for (i = 0;i < n; i++)?
24. 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");
}
#include <stdio.h>
int main()
{
do
printf("In while loop ");
while (0);
printf("After loop\n");
}
25. 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");
}
}
#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");
}
}
26. 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;
}
}
#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;
}
}
27. Which datatype can accept the switch statement?
28. Which loop is most suitable to first perform the operation and then test the condition?
29. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int k = 0;
for (k)
printf("Hello");
}
#include <stdio.h>
void main()
{
int k = 0;
for (k)
printf("Hello");
}
30. What will be the output of the following C code?
#include <stdio.h>
int main()
{
while ()
printf("In while loop ");
printf("After loop\n");
}
#include <stdio.h>
int main()
{
while ()
printf("In while loop ");
printf("After loop\n");
}
Read More Section(Control Structures)
Each Section contains maximum 100 MCQs question on Control Structures. To get more questions visit other sections.