Nested If

Nested if statement is placed inside other if block.

Syntax

Basic example

Let's validate the price of a product in smartphone store and print proper messages about it.

The rule is that price must be above 500 $ and below 2000 $.

Output:

Since both conditions at line 3 and 6 are true, the code at line 7 is executed.