|
|
Continue Statement - C++ Control Structures
|
Tutorials

Cpp

|
Topic |
Using Continue Statement in C++?
How to skip current iteration of a loop?
|
|
Explanation |
|
Continue statement is used to skip the code after the "continue" and go ahead with the next iteration of a loop.
Difference between "break" and "continue":
The "break" statement terminates the current statement, but a "continue" statement terminates the
current iteration of a loop by not executing statements after it.
Syntax:
continue;
Example:
#include <iostream.h>
void main()
{
int i;
cout << "Enter a integer::" << '\n';
cin >> i;
while(i >0)
{
cout << "Value of i is::" << i <
|
Result:
Enter a Integer::3
Value of i is:: 3
SKIPPED
Value of i is:: 1
Not skipped
Exited Loop
In the above example only when the value of i is 2 the "cout" statement with message "skipped" is executed,
and the "cout" statement with the message is skipped.
|
| Note |
C++ is one of the most used programming languages in the world. Also known as "C with Classes".
Hope you enjoy this tutorial. Do send your feedback or suggestions on this C++ tutorial. This is a copyright content.
|
|
|
|