Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training

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.

Ads

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:

Download this example.

Advertisements

Ads
Share on Google+Share on Google+

Nested If Statements

Posted on: February 7, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

Ads
 

Discuss: Nested If Statements  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads