Decision Making Statements
The following are the decision making statements in C++ :-
  • if Statements
  • if-else Statements
  • else-if Statements

if Statements

If the condition in the if statement evaluates to true, then the specified set of statement block is executed, otherwise the if statement exits.

The syntax of the if statement is as follows: -
if(condition)

{

statement-block;

}


if-else Statements

If the condition in the if statement evaluates to true, then the specified set of statement block is executed, otherwise the statement-block in the else block is executed. In other words, the if-else statements contains a set of statement-block for both the cases, either the condition evaluates to true or false.
The syntax of the if statement is as follows: -

if(condition)

{

statement-block;

}

else

{

statement-block;

}


else-if Statements What is the need of else-if statement when if-else has both the options, i.e. Either the specified conditions evaluates to true or false, a corresponding set of statement block will be executed depending upon the condition status. But what if, when we want to use multiple conditions with the if statement. For this, C++ provides an else-if block.

The syntax is as follows:-

if(condition)

{

statement-block;

}

else if(condition)

{

statement-block;

} ..... ......... ......//multiple else-if block of conditions will be used as per requirement.

else if(condition)

{

statement-block;

}

else

{

statement-block;

}

********************************************************************************

Seamless Texture Generator