C++ Loops - Devbhoomi

FREE JOB ALERT & ONLINE TUTORIALS

Hot

Post Top Ad

Saturday 7 October 2017

C++ Loops

C++ Loops


Sometimes it is necessary in the program to execute the statement several times, and C++ loops execute a block of commands a specified number of times, until a condition is met. In this chapter you will learn about all the looping statements of C++ along with their use.

What is Loops in C++?

There may arise some situations during programming where programmers need to execute block of code several times (with slight variations sometimes). In general, statements get executed sequentially with a C++ program, one statement followed by another. C++ provides statements for several control structures along with iteration / repetition capability that allow programmers to execute a statement or group of statements multiple times.
C++ supports following types of loops:
All are slightly different and provides loops for different situations.
Figure – Flowchart of Looping:

C++ Loop Control Statements

Loop control statements is used to change normal sequence of execution of loop.
StatementSyntaxDescription
break statementbreak;Is used to terminate loop or switch statements.
continue statementcontinue;Is used to suspend the execution of current loop iteration and transfer control to the loop for the next iteration.
goto statementgoto labelName;labelName: statement;It’s transfer current program execution sequence to some other part of the program.


No comments:

Post a Comment

Post Top Ad