What will be the output of the following code? int main() {
What will be the output of the following code?
#include <stdio.h>
int main() {
int x = 5;
switch(x) {
case 5:
printf("Five");
default:
printf("Default");
}
return 0;
}
Show answerHide answer
Correct answer: (D) FiveDefault
Explanation
case 5 matches and prints "Five". There is no break, so control falls through to default and also prints "Default", giving FiveDefault.