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:

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Nested If Statements
Post your Comment