Which of the following cannot be checked in a switch-case statement?

By Priyanshu Vaish|Updated : July 7th, 2022

Which of the following cannot be checked in a switch-case statement?

  1. Character
  2. Integer
  3. Float
  4. enum

Answer: C. Float

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

Follow us for latest updates