logo
logo
Sign in

C switch...case Statement

avatar
Tech Mekrz
C switch...case Statement

The if..else..if ladder allows you to execute a block code among many alternatives.

If you are checking on the value of a single variable in if...else...if, it is better to use switchstatement.

The switch statement is often faster than nested if...else (not always).

Also, the syntax of switch statement is cleaner and easy to understand.

// code to be executed if n is equal to constant1;

// code to be executed if n is equal to constant2;

collect
0
avatar
Tech Mekrz
guide
Zupyak is the world’s largest content marketing community, with over 400 000 members and 3 million articles. Explore and get your content discovered.
Read more