Category: Selection Structure

C++ If Statement (with example programs)

The “if” statement is used to execute or to ignore a statement after the testing condition. This is a decision making and the simplest form of selection structure. The “if” statement evaluates the condition. If the given condition is true, then statement or group of statements following the ‘if’ structure is executed. If the given condition […]

C++ if-else Statement with examples

The “if-else” structure is another form of if statement that is specially used for making two way decision. In its structure, one test condition and two blocks of statements are used to make decision. When the given condition is true, the first block is executed whereas other block is ignored. Similarly, second block is executed if the […]

C++ if-else-if Statements with examples

The if-else-if structure is also known as nested if else structure or multiple if else structure. It is used to execute one block of statements from multiple blocks of statements.In C++ if else if structure, multiple conditions and multiple blocks of statements are given. When any of the given condition is true, the statements associated with that condition are executed. In this […]

C++ Nested If Statement with examples

When multiple conditions have to check in the program then “nested if statements” are used to solve the problem. The nested if structure may contain multiple if statements that may be nested up to any level.If statement within another if statement is called nested if structure. The ‘if statement’ that contains another if statement is called outer if statement. […]

Switch statement in C++

In C++ programming, a switch statement is a type of selection control mechanism used to select one choice when multiple choices are given. It can be used as an alternative of if else if structure.Switch statements function somewhat similar to the if statement usually used for option menu selections. The switch structure contains only one […]

Introduction to C++ Selection Structure

Selection structures are how C++ programsmake decisions according to the conditional statement. When a control expression in an if statement is evaluated to be true, the statements associated with the structure are executed.The selection structure is the type of control structure that is used for selecting a statement or set of statements for execution on […]