Skip to content
Related Articles

Related Articles

C Quiz – 104 | Question 5
  • Difficulty Level : Basic
  • Last Updated : 07 Oct, 2015

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

Attention reader! Don’t stop learning now. Get hold of all the important C++ Foundation and STL concepts with the C++ Foundation and STL courses at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :