What restriction applies to the case labels of a switch in C?
-
A
They must be listed in ascending order
-
B
They must be integer constant expressions
Correct answer
-
C
They must be distinct string literals
-
D
They must be variables of type int
Correct answer
B. They must be integer constant expressions
11 views
Explanation
Each case label must be an integer constant expression whose value is known at compile time.
Reference
Asked in: NTS, PPSC IT, Campus Interviews
Doubts & discussion
Not sure why the answer is B? Ask here and get an explanation.
Ask a doubt about this MCQ