do-while

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). Notice that statement will always be executed at least once, since the test for repetition does not occur until the end of the first pass through the loop. The statement can be either simple or compound. It must include some feature that eventually alters the value of expression so that...

Control Statements in C Plus Plus (C++)

Control statements alter the flow of execution of the programs. Control statements can be broadly divided into three categories: Decision-making or Conditional Statements (Branching and Selection) if statement if-else statement switch statement Loop Statements for statement while statement do-while statement Breaking Control Statements break statement continue statement goto statement