Question 3
Back to Exercise
What is the output of the following C program?
#include <stdio.h>
int main(void) {
int n = 2;
switch (n) {
case 1: printf("one ");
case 2: printf("two ");
case 3: printf("three ");
default: printf("other");
}
printf("\n");
return 0;
}
- A two three other Correct
- B two
- C two other
- D one two three other
Correct Answer: Option A
Execution enters at case 2 and, with no break anywhere, falls through every following label, including default.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!