A situation can arise if you have executed a section of code multiple times. In general, statements are performed sequentially: First, followed by second, are performed in one function.
Programming languages give multiple control structures to make execution routes more sophisticated.
The following loops are provided in the C++ programming language for handling loop requirements.
Sr.No | Loop Type & Description |
---|---|
1 | while loop Repeats some statements while a given condition proves to be true. It checks the condition before the execution of the body of the loop |
2 | for loop
Execute some statements many times and abbreviates the code for the loop variables’ management |
3 | do...while loop
It is similar to a ‘while’ statement, just that it checks the condition after the loop body’s execution |
4 | nested loops You get to use some loops inside other ‘for,’ ‘while,’ or ‘do..while,’ loop. |
Repeats some statements while a given condition proves to be true. It checks the condition before the execution of the body of the loop
Execute some statements many times and abbreviates the code for the loop variables’ management
It is similar to a ‘while’ statement, just that it checks the condition after the loop body’s execution
You get to use some loops inside other ‘for,’ ‘while,’ or ‘do..while,’ loop.
Closed control statements vary its typical sequence execution. All automatic objects produced within that scope are deleted when execution exits an area.
C++ supports the following statements of control.
Sr.No | Control Statement & Description |
---|---|
1 | break statement
Termination of the loop or decision statement and then transferring the statement’s execution immediately following the decision statement or the loop. |
2 | continue statement
It causes skipping the loop for the remaining body and then instantly retest its condition before reiterating |
3 | goto statement Transferring the control to labeled statement. Even though it isn’t advised using the goto statement in a program |
|