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.

Editorial Team at Geekinterview is a team of HR and Career Advice members led by Chandra Vennapoosa.

Editorial Team – who has written posts on Online Learning.


Pin It

One thought on “What are the limitations with switch statement?

  1. logical and relational operators are not allowed in a switch -case.make the correction in the given example case K>=20 : is a relational expression and not a logical expression

Leave a Reply