What will be the output of the program? #include<stdio.h> int main() { int i=4; switch(i) { default: printf("This is default "); case 1: printf("This is case 1 "); break; case 2: printf("This is case 2 "); break; case 3: printf("This is case 3 "); } return 0; }

Correct Answer: This is default This is case 1

Explanation:

In the very begining of switch-case statement default statement is encountered. So, it prints "This is default".


In default statement there is no break; statement is included. So it prints the case 1 statements. "This is case 1".


Then the break; statement is encountered. Hence the program exits from the switch-case block.


More Questions from Control Instructions

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion