C++ Break Statement in Loop Program
In this tutorial, we will learn how to demonstrate the concept of break statement in loops, in the C++ programming language.
using namespace std;
cout << "\n\nWelcome to Studytonight :-)\n\n\n";
cout << " ===== Program to understand the break keyword ===== \n\n";
// Local variable declaration and initialization:
int n = 10;
// do loop execution
cout << "Value of variable n is : " << n << endl;
n = n + 1;
if (n == 15)
// terminate the loop and execute the next statement following it.
cout << "\n\nExecuting the break statement and terminating the loop.\n\n";
} while (n < 20);
cout << "The value at which the loop got terminated is : " << n << "\n\n\n";
We hope that this post helped you develop a better understanding of the concept of break statement in loops, in C++. For any query, feel free to reach out to us via the comments section down below.
Keep Learning : )