Hello and Asalam o Alikum. I hope you all are fine by the grace of Allah Almighty.
Today I am here with a new program that explains the purpose of "continue" statement in C++.
Below is the source code of an example of "continue" statement.
Today I am here with a new program that explains the purpose of "continue" statement in C++.
"Continue" statement
It is used in the body of the loop. It is used to move the control to the start of the loop body. When this statement is executed, the remaining statements of current iteration are not executed. The control directly moves to the next iteration.Below is the source code of an example of "continue" statement.
Source code
Output
Explanation
There are two "cout" statements in the above example. One statement is before the "continue" statement and the next "cout" statement is after the "continue" statement.
Remember that the second "cout" statement,"Good bye." is never executed. The reason is that each time the "continue" statement is executed, the control moves back to the start of the loop. This process continues until the condition of the loop becomes false.So, "Hello world." will be displayed 5 times and "Good bye." will never be displayed.
No comments:
Post a Comment