Nested if Else



If a if statement is used within an if statement, then such a control structure is called as Nested If.
Syntax:
    if(condition)
        {
        if (condition)
            {
                     Statement;
            }
        else
        {
             Statement;
        }
        
        else
        {
             Statement;
        }
            Next statement;

Disadvantages of nested if-else:

There are three disadvantages of nested if-else. They are as follows:-

  • A no. of increase in the level of identation also goes on increasing. As a result the whole program creeps to the right.
  • Care needs to be exercise to match corresponding ‘if’s’ and ‘else’s’.
  • Care needs to be exercise to match corresponding pair of bases.
Flow chart of nested if else
nested if