Nested-if Statement With Example

Nested-if Statement ?

The statement executed as a result of an if statement or else clause could be another if statement. These are called nested if statements. An if statement inside another if or else statement is termed as nested-if

A nested if is an if statement that is the target of another if statement. Nested if statements means an if statement inside another if statement.

It is always legal to nest if-else statements, which means you can use one if or else if statement inside another if or else if statement(s).

Syntax :

Flow Chart:


Example 1:



Output :

  
i is smaller than 15
i is smaller than 12 too

Example 2:



Output :

 X = 30 and Y = 10

Example 3:



Output :

 aimtocode roll no is 20