Category: Control Statements in C++

goto statement in C++ 3

goto statement in C++

The goto statement is used to alter the normal sequence of the program execution by transferring control to some other part of the program. In its general form, the goto statement is written as: goto label; Where label is an identifier that is used to label the target statement to which control will be transferred. Control may be transferred to any other statement within the program. The target statement must be labeled, and the label must be followed by a colon. Thus, the target statement will appear as: label: statement Each labeled statement within the program must have a unique...

continue statement in Cpp 0

continue statement in C++

The continue statement is used to bypass the remainder of the current pass through a loop. The loop does not terminate when a continue statement is encountered. Rather, the remaining loop statements are skipped and the computation proceeds directly to the next pass through the loop. The continue statement can be included within a for, a while or a do-while statement. The continue statement is written simply as: continue; without any embedded expressions or statements. The continue is a keyword in the C++ program and the semicolon must be inserted after the continue statement.

break statement in Cpp 0

break statement in C++

The break statement is used to terminate loops or to exit from a switch. It can be used within a for, a >code>while, a do-while or a switch statement. The break statement is written simply as: break; without any embedded expressions or statements. The break is a keyword in the C++ program and the semicolon must be inserted after the break statement. We have already seen the use of break statement within the example of switch statement (Click here). The break statement causes a transfer of control out of the entire switch statement, to the first statement following the switch...

do-while statement in Cpp 1

do-while statement in C++

The do-while loop is another repetitive loop used in C++ programs. When a loop is constructed using the while statement, the test for continuation of the loop is carried out at the beginning of each pass. Sometimes, however, it is desirable to have a loop with the test for continuation at the end of each pass. This can be accomplished by means of do-while statement. The general form of the do-while statement is do{ statement 1; statement 2; …. …. } while(expression); The statement will be executed repeatedly, as long as the value of expression is true (i.e., is non-zero)....