C++ Switch Case without Break Statement Program
In this tutorial, we will learn how to demonstrate the concept of Switch case without break statement, in the C++ programming language.
C++ Switch Case:
In Programming, a Switch Case is just an alternative for the multiple if-else blocks. It is used to execute the block of the code only when a particular condition is fulfilled. A break statement is used to stop the code flow from entering into the remaining blocks and hence making it directly move out of the switch block when even a single condition is fulfilled.
break statement, the code gets into each of the cases following the case that matches. The example discussed in the below code will help you understand the functionality provided by the break statement within a switch case.
using namespace std;
cout << "\n\nWelcome to Studytonight :-)\n\n\n";
cout << " ===== Program to demonstrate the concept of Switch Case without break statement, in CPP ===== \n\n";
//variable to run the Switch case with
int sw = 1;
cout << "\n\n***** Entering the Switch case with value 1 ***** \n\n";
//Logic of Switch case with break statement
cout << "\nInside Case 1\n";
cout << "\nInside Case 2\n";
cout << "\nInside Case 3\n";
cout << "\nInside Case 4\n";
cout << "\nInside Case 5\n";
cout << "\nInside the Default Case\n";
cout << "\n\n***** Exiting the Switch case ***** \n\n\n";
We hope that this post helped you develop a better understanding of the concept of Switch Case without a break statement, in C++. For any query, feel free to reach out to us via the comments section down below.
Keep Learning : )