hamburger

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?

  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:

Our Apps Playstore
POPULAR EXAMS
SSC and Bank
Other Exams
GradeStack Learning Pvt. Ltd.Windsor IT Park, Tower - A, 2nd Floor, Sector 125, Noida, Uttar Pradesh 201303 help@byjusexamprep.com
Home Practice Test Series Premium