C Programming - Control Instructions - Discussion
Discussion Forum : Control Instructions - General Questions (Q.No. 5)
5.
Which of the following cannot be checked in a switch-case statement?
Answer: Option
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.
Discussion:
18 comments Page 1 of 2.
K.suriya said:
1 decade ago
Case value must be an int, char, enum but not double and float float is the answer for this question.
Hemanth said:
1 decade ago
Why enum cannot be the answer? Any reason plzzzzz.
Tarun Singh KiiT said:
1 decade ago
Switch case does not accept the float value.
Praveen said:
1 decade ago
Why enum cannot be the answer? Any reason......
Diya said:
1 decade ago
Can enum be checked in a switch-case statement?
Pruthvi said:
1 decade ago
Yes. Enum can be checked. As an integer value is used in enum.
Vinita said:
1 decade ago
Thanks Pruthvi.
Manojit said:
1 decade ago
The switch/case statement convert the float into an int and use it, so long as the resulting values and functionality meet your functional requirements.
Rangasamy said:
1 decade ago
Can you explain the use of enum in switch statement with a program ?
Priyanka said:
1 decade ago
You declare enum as enum{tamil, english, hindi}.
So sequential number is given for languages namely 0, 1, 2.
As integers are made use you can use enum in switch case statement. :).
So sequential number is given for languages namely 0, 1, 2.
As integers are made use you can use enum in switch case statement. :).
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers