Loop Control Statements

A loop (also referred to as an iteration or repetition) is a sequence of statements which is specified once but which may be carried out several times in succession. The code “inside” the loop (the body of the loop) is obeyed a specified number of times, or once for each of a collection of items, or until some condition is met. A block or group of statements executed repeatedly until some condition is satisfied is called Loop. The group of statements enclosed within curly brace is called block or compound…

Read More

Switch-Case control statements

In addition to two-way selection, most programming languages provide another selection concept known as multi-way selection. Multi-way selection chooses among several alternatives. C++ has two different ways to implement multi-way selection. The switch statement and else-if construct If for suppose we have more than one valid choices to choose from then we can use switch statement in place of if statements. Syntax: As you can see in the above scheme the case and default have a “break;” statement at the end of block. This expression will cause the program to…

Read More

Decision making statements

These statements are used to control the flow of execution of a program by making a decision depending on a condition, hence they are named as decision making statements. Decision making statements are of four types. Simple if if else nested if else If else ladder 1. Simple if Statement if the test expression is true then if statement executes statements that immediately follow if Syntax: Example: 2. if-else Statement If test expression is true block of statements following if are executed and if test expression is false then statements…

Read More