#### Control Instructions

21

Which of the following errors would be reported by the compiler on compiling the program given below?

#include<stdio.h>
int main()
{
int a = 5;
switch(a)
case 1:
printf("First");

case 2:
printf("Second");

case 3 + 2:
printf(Third");

case 5:
printf("Final");
break;

}
return 0;
}

A. There is no break statement in each case.
B. Expression as in case 3 + 2 is not allowed.
C. Duplicate case case 5:
D. No error will be reported.

22

Point out the error, if any in the while loop.

#include<stdio.h>
int main()
{
int i=1;
while()
{
printf("%d\n", i++);
if(i>10)
break;
}
return 0;
}


A. There should be a condition in the while loop
B. There should be at least a semicolon in the while
C. The while loop should be replaced with for loop.
D. No error

23

Point out the error, if any in the program.

#include<stdio.h>
int main()
{
int a = 10;
switch(a)
{
}
printf("This is c program.");
return 0;
}


A. Error: No case statement specified
B. Error: No default specified
C. No Error
D. Error: infinite loop occurs

24

Point out the error, if any in the for loop.

#include<stdio.h>
int main()
{
int i=1;
for(;;)
{
printf("%d\n", i++);
if(i>10)
break;
}
return 0;
}

A. There should be a condition in the for loop
B. The two semicolons should be dropped
C. The for loop should be replaced with while loop.
D. No error

25

What will be the output of the program?

#include<stdio.h>
int main()
{
int x, y, z;
x=y=z=1;
z = ++x || ++y && ++z;
printf("x=%d, y=%d, z=%d\n", x, y, z);
return 0;
}


A. x=2, y=1, z=1
B. x=2, y=2, z=1
C. x=2, y=2, z=2
D. x=1, y=2, z=1