Nested If Statements
We use the if condition to check if the particular condition is true then it should perform a certain task, and if a particular condition is not true then it should do some other tasks. Consider a situation where we have to use multiple if conditions then there we have to use nested if statements.
Code of the program is given below:
<HTML> <HEAD> <TITLE>Nested if Statements</TITLE> </HEAD> <BODY> <H1>Nested if Statements</H1> <% double value = 5; if (value != 0) { if (value > 0) out.println("The result = " + (1 + value)); else out.println("The result = " + (1 - value)); } %> </BODY> </HTML> |
The output of the program is given below: