Home / C Programming / Control Instructions :: Discussion

Discussion :: Control Instructions

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

  2. A.
    Character
    B.
    Integer
    C.
    Float
    D.
    enum

    View Answer

    Workspace

    Answer : Option C

    Explanation :

    The switch/case statement in the c language is defined by the language specification to use an int value, so you can not use a float value.

     switch( expression ) {     case constant-expression1:    statements 1;     case constant-expression2:    statements 2;         case constant-expression3:    statements3 ;     ...     ...     default : statements 4; } 

    The value of the 'expression' in a switch-case statement must be an integer, char, short, long. Float and double are not allowed.


Be The First To Comment