Control Instructions

Q1: Point out the error, if any in the program.
#include<stdio.h>
int main()
{
    int i = 1;
    switch(i)
    {
        printf('This is c program.');
        case 1:
            printf('Case1');
            break;
        case 2:
            printf('Case2');
            break;
    }
return 0;
}

A Error: No default specified

B
Error: Invalid printf statement after switch statement

C No Error and prints "Case1"

D None of above

ANS:A - Error: No default specified

switch(i) becomes switch(1), then the case 1: block is get executed. Hence it prints 'Case1'. printf('This is c program.'); is ignored by the compiler. Hence there is no error and prints 'Case1'.



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.