Certain task requires execution of some statement ignoring the rest these statement can be called decision making statement. Decision making structures require that the programmer specify one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false.

    If statement

    If-else statement

    Nested if statement

    Switch case statement


1. If Statement

The if statement is used to control the sequence of statement it changes the sequential execution.

Syntax -

if(condition){

    Statement (s)

    Statement (s)

} Statement (x)


If-Else Statement

The if else expression execute a group of statement if test expression is true it also executes another group of statement if the text expression is False hence in either case a group of statement is executed.

Syntax -

If (condition){

    Statement (s)

    true block

}

else{

    Statement (s)

    false block


Nested If-Else Statement

If is perfectly all right if we write an enter if else with in the body of the if statement this is called nesting this helps in multi decision making.

Syntax –

If (condition){

    If(condition){

        Statement (s)

    }

    else{

        Statement (s)

    }

}

else{

    if(condition){

        statement2 (s)

    }

    else{

        statement3 (s)

    }

}statement-X 


Switch Case Statement

The control statement that allows us to make a decision from the number of choice is called switch case default this statement test the value of a given expression against a list of case value and when a match is found a block of statement associates with that case is executed the break statement at the end of each block signed at the end of a particular case and causes an exit from the switch statement.

Syntax - 

switch(expression){

    case 1: constant-expression :

        statement(s);

        break; //optional

    case 2: constant-expression :

        statement(s);

        break; //optional

    default : //Optional

        statement(s);

}