What are the limitations with switch statement?

Switch statement is a powerful statement used to handle many alternatives and provides good presentation for C program. But there are some limitations with switch statement which are given below:


Logical operators cannot be used with switch statement. For instance



case k>=20:



is not allowed


Switch case variables can have only int and char data type. So float or no data type is allowed.


For instance in the switch syntax given below:



switch(ch)

{

case 1:

statement-1;

break;

case 2:

statement-2;

break;

}



In this ch can be integer or char and cannot be float or any other data type.

Questions by GeekAdmin   answers by GeekAdmin

Showing Answers 1 - 1 of 1 Answers

saurav kant prasad

  • Sep 2nd, 2006
 

THE CERTAIN LIMITATIONS WHILE UISING SWITCH CASE IS AS FOLLOWS::::::1. #INCLUDE VOID MAIN(){INT J=2;CHAR CH; SWITCH(CH){CASE 1:STATEMENT; BREAK; CASE J:STATEMENT2;//WE CAN'T WRITE LIKE THIS BREAK;CASE........}2.INT K=1;SWITCH(){ CASE1:STATEMENT1; BREAK;CASE 2*K+1:ST2; BREAK;}

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions