Switch Case Flowchart
Switch case flowchart: one value is compared with each case in turn, the first match runs its action and then breaks out, and the default catches everything else. With a trace for day = 2 and tested C, Java and Python code.
Switch case flowchart: one value is compared with each case in turn, the first match runs its action and then breaks out, and the default catches everything else. With a trace for day = 2 and tested C, Java and Python code.
Study guide
A switch statement compares one value against a list of cases and runs the action of the first case that matches. In a switch case flowchart each case is a diamond in a ladder, each Yes arrow runs one action and then jumps to the end (that jump is the break), and the last No arrow lands on the default.
The example turns a day number into a day name: 1 is Monday, 2 is Tuesday, 3 is Wednesday, and anything else is invalid.
break.else of an if-else chain.Follow the flowchart with day = 2. Each row is one shape the flow reaches.
| Step | Shape | day | Test | Printed | Next shape |
|---|---|---|---|---|---|
| 1 | Read day | 2 | no test | nothing | day == 1? |
| 2 | day == 1? | 2 | 2 == 1: No | nothing | day == 2? |
| 3 | day == 2? | 2 | 2 == 2: Yes | nothing | Print "Tuesday" |
| 4 | Print "Tuesday" | 2 | no test | Tuesday | End |
Case 3 and the default are never reached. As soon as one case matches, break skips everything below it.
READ day
CASE day OF
1: PRINT "Monday"
2: PRINT "Tuesday"
3: PRINT "Wednesday"
OTHERWISE: PRINT "Invalid day"
ENDCASE
day = int(input())
# Python 3.10+ has match, its version of switch.
match day:
case 1:
print("Monday")
case 2:
print("Tuesday")
case 3:
print("Wednesday")
case _: # default
print("Invalid day")
#include <stdio.h>
int main(void) {
int day;
scanf("%d", &day);
switch (day) {
case 1:
printf("Monday\n");
break;
case 2:
printf("Tuesday\n");
break;
case 3:
printf("Wednesday\n");
break;
default:
printf("Invalid day\n");
}
return 0;
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int day = in.nextInt();
switch (day) {
case 1:
System.out.println("Monday");
break;
case 2:
System.out.println("Tuesday");
break;
case 3:
System.out.println("Wednesday");
break;
default:
System.out.println("Invalid day");
}
}
}
2
Tuesday
All three programs were compiled and run with the input 2 before publishing. Python has no switch keyword; match (Python 3.10 and later) does the same job and never falls through, so it needs no break.
case marks >= 50 is not allowed. Ranges need an if-else chain.Tuesday and then Wednesday.
Case 2 matches and prints Tuesday. With no break, the flow falls into case 3's action and prints Wednesday. The break after case 3 then stops it, so Invalid day is not printed.
Three diamonds, and it prints Invalid day.
7 fails day == 1, day == 2 and day == 3 in turn, so the last No arrow leads to the default.
READ day
IF day == 1 THEN
PRINT "Monday"
ELSE IF day == 2 THEN
PRINT "Tuesday"
ELSE IF day == 3 THEN
PRINT "Wednesday"
ELSE
PRINT "Invalid day"
ENDIF
The flowchart is the same picture. That is why a switch case flowchart looks like an else-if ladder.
| Symbol | Shape to draw on paper | Where it appears here | Why |
|---|---|---|---|
| Terminator | Rounded box | Start and End | All four paths meet at the one End. |
| Input/output | Parallelogram | Read day and the four Print steps | They take input or show output. |
| Decision | Diamond | day == 1?, day == 2?, day == 3? | One diamond per case, each with labelled Yes and No exits. |
| Flow line | Arrow | The arrows labelled break | A break is just an arrow that jumps past the remaining cases to End. |
In the interactive diagram every step is a labelled card: the small word above each step names its kind (process, decision or data). When you draw this flowchart by hand, use the standard shapes in the table. The full list is on the flowchart symbols page.
Each link opens the editor with a prompt already filled in. Change the wording, then generate your own flowchart.
Download the Switch Case Flowchart as a PNG or SVG, or open it in the studio to edit your own copy. To draw a similar flowchart from a description, use the flowchart generator; for notation and a step-by-step walkthrough, read how to make a flowchart; and browse more flowchart examples for related layouts.
Type any system, process, or schema in plain English. ChartCraft will draw it in seconds.