Control Instructions

Q1: 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.

ANS:A -

There is no break statement in each case.

Because, case 3 + 2: and case 5: have the same constant value 5.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.