x

C++ Decision Control Statements

PREV     NEXT

What are decision control statements?

The decision control statements are the decision making statements that decides the order of execution of statements based on the conditions. In the decision making statements the programmer specify which conditions are to be executed or tested with the statements to be executed if the condition is true or false.


 Some of the decision control statements are

  • if statement
  • if-else statement
  • nested if statements
  • switch statement

Let us discuss all these statements briefly.

If statement

The if statement consists a condition which is followed by one or some of the statements, if the condition is true then the statements will be executed or else not. This statement is the simple and easy decision control statement.

Let us have a look at the syntax:

Let us have a look at the example:

If – Else Statement

In the if-else statement the if statement is followed by the else statement which will execute when the expression is false.


Let us have a look at the syntax:

Let us have a look at the example:

We can have the nested if statements also with else statements comparing the different conditions.

Let us understand this through an example:

Switch Statement

The switch statement allows the variable to be tested for equality against a list of values. In the switch statement every value is called case and the variable is switched on is checked for each case.

Let us have a look at the syntax:

Let us have a look at the example:

PREV     NEXT



Like it? Please Spread the word!