C Quiz – 104 | Question 5

Which of the following statement is correct for switch controlling expression?

(A) Only int can be used in “switch” control expression.
(B) Both int and char can be used in “switch” control expression.
(C) All types i.e. int, char and float can be used in “switch” control expression.
(D) “switch” control expression can be empty as well.


Answer: (B)

Explanation: As per C standard, “The controlling expression of a switch statement shall have integer type.” Since char is prompted to integer in switch control expression, it’s allowed but float isn’t promoted. That’s why B is correct statement.

Quiz of this Question



My Personal Notes arrow_drop_up


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.