Write limitations of switch case.

Palak Patel08 May 2026
Write limitations of switch case.

Limitations of switch Case in C Programming

The switch case statement is used for multiple decision-making in C programming.

Although it is useful for handling many choices, it also has several limitations.

Main Limitations of switch Case

  • Works Only with Integer or Character Values
    The switch statement does not directly support float or double data types.
  • Cannot Use Relational Operators
    Operators like >, <, and >= cannot be used inside case labels.
  • Case Values Must Be Constant
    Variables and runtime expressions are not allowed as case labels.
  • Only Equality Checking Is Possible
    Switch compares values only for equality.
  • Duplicate Case Values Are Not Allowed
    Each case label must contain a unique value.
  • Break Statement Is Necessary
    Without break, execution continues to the next case automatically.

Example of switch Case

#include <stdio.h>

int main()
{
    int choice = 2;

    switch(choice)
    {
        case 1:
            printf("One");
            break;

        case 2:
            printf("Two");
            break;

        default:
            printf("Invalid Choice");
    }

    return 0;
}

Conclusion

The switch case statement is useful for simple menu-driven programs.

However, it cannot handle complex conditions and advanced comparisons.

Therefore, programmers often prefer if-else statements for complicated decision-making.

Comments

0/1000

No comments yet. Be the first!