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.
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
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses
are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!