C Switch Case Statement

In this tutorial you will learn about the C Switch Case Statement and its application with practical example.

In C programming, It evaluates an expression against multiple cases in order to identify the block of code to be executed. A switch case statement is a simplified form of the Nested if-else statement, it helps to avoid a long chain of if..else if..else statements.

Flow Diagram

c-switch-case-statement-flowchart

C Switch Case Statement Syntax

Below is the general syntax of switch case in c programming:

Syntax:-

Example of Switch Case

Below is a simple example to demonstrate the use of the present statement in c programming:

Example:-

In the above program, we have an integer variable dayOfWeek with an initial value of 5, and we pass this variable as an expression to the following switch statement, value of dayOfWeek is tested with multiple cases to identify the block of code to be executed. When we run the above C program, will see the following output –

Output:-

c-switch-case-statement

In this tutorial we have learn about the C Switch Case Statement and its application with practical example. I hope you will like this tutorial.