break and continue Statements
break Statement
The break statement is used to alter the flow of control. When a break statement is executed in a while loop, for loop, do-while loop or switch statement, it causes immediate exit from that statement. Program execution continues with the next statement. Common uses of the break statement are to escape early from a loop or to skip the remainder of a switch statement.
The program written below demonstrates the break statement in a for-loop.
When the if-statement detects that x has become 5, break statement is executed. This terminates the for-loop and the program continues from cout after the for-loop.

continue Statement
The continue statement is also used to alter the flow of control. When it is executed in a while loop, for loop or do-while loop, it skips the remaining statements in the body of the control loop and performs the next iteration of the loop.
An example of continue statement is shown below,

Output:

Some programmers feel that break and continue statements violate the norms of structured programming since the effects of these statements can be achieved by structured programming technique. The break and continue statements, when used properly, perform faster than the corresponding structured technique.
- Conditional Operators and Switch Statements
C++ has an operator that can be used as an alternative to an if-statement. This operator is called the conditional operator (?:). This operator can be used to replace an if-else statement of the following general form: if(expression) { statements ; - - } else { statements ; - - } The above form of [...]...
- goto Statement
In programming, significance has always been given to use of structured programming technique to build reliable software that are easy to debug, maintain and modify. In some cases, performance is more important than strict obedience to structured programming technique. In these cases, some unstructured programming technique may be used. For example, we can use break [...]...
- if Statement
An if/else statement tests a particular condition, if the condition evaluates to true, a course-of-action is followed i.e. a statement or a set of statements is executed. Otherwise another set of instructions are executed (the else block). Such statements are called program control statements that control the flow of execution in a program. Normally, the [...]...
- Java Loops – For, While, and Do
Java supports three types of loops: For, While, and Do. The Java For Loop The Java for loop is a looping construct which continually executes a block of statements over range of values. Java for Loop Syntax The syntax of a for loop in Java is: for (initialization; termination; increment) { statement } Example Java [...]...
- Iterations
An Iteration involves repeating some portion of a program, a specified number of time or until a particular condition is satisfied. This repetitive operation in C and C++ is achieved through for, while and do-while loop. How does a for loop work? A for loop is the easiest iteration loop to understand the C and [...]...




