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 2 of 2.
Pruthvi said:
1 decade ago
Yes. Enum can be checked. As an integer value is used in enum.
Hemanth said:
1 decade ago
Why enum cannot be the answer? Any reason plzzzzz.
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?
Tarun Singh KiiT said:
1 decade ago
Switch case does not accept the float value.
Raj said:
10 months ago
Super. Thanks all for the explanation.
(2)
Aditya Chauhan said:
1 decade ago
Can We use long in switch case?
Vinita said:
1 decade ago
Thanks Pruthvi.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers