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:
Comments
write a comment