Which of the following cannot be checked in a switch-case statement?
By BYJU'S Exam Prep
Updated on: September 25th, 2023
Which of the following cannot be checked in a switch-case statement?
- Character
- Integer
- Float
- enum
Answer: C. Float
Table of content
Float cannot be checked in a switch-case statement.
Solution
You cannot use a float value in a switch/case statement written in the C language because the language specification requires it to use an int value.
The structure of the switch case is
switch( expression )
{
case constant-expression1: statements 1;
case constant-expression2: statements 2;
case constant-expression3: statements3 ;
…
…
default : statements 4;
}
In a switch-case statement, the value of the expression must be an integer, char, short, or long. Double and float are disallowed.
☛ Related Questions: