In switch statements multiple cases are used. Each case contain one condition. The case which is matched with the switch variable will be executed.
Syntax:
Output:
Well done
your grade is : B
your grade is : B
In the above program, initially we have declared variable grade as B. And totally six cases are introduced with different conditions. In which the variable grade is assigned as B so case B matched and thus case "B" block is executed.
If none of the case is matched, the default block will be executed.
No comments:
Post a Comment