Nested-if Statement with example
Nested-if Statement ?
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.
e can place 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 :
if( boolean_expression 1) {// Executes when the boolean expression 1 is true if(boolean_expression 2) {// Executes when the boolean expression 2 is true } }
Flow chart:

Example 1:
Output :
Enter an integer: 0 You entered 0. This line is always printed.
Example 2:
Output :
Value of a is 100 and b is 200 Exact value of a is : 100 Exact value of b is : 200