Introduction
Figure 1: If else statement Figure 2: Switch statement
From the figures above, it shows that if else statement could be replaced with switch statement.
For example, when the marks is between 90 to 100, it will execute the grade A+ and break out of the switch. If not, it will continue with the following marks etc.
File(s) to download
-
Download grade.cpp
grade.cpp Details
- Thursday, 04 February 2021 [791 B] -
Download grade_switch.cpp
grade_switch.cpp Details
- Thursday, 04 February 2021 [1.2KB]