Search This Blog

UI/UX Design | Web Development | Mobile Application Development

Whether you need UI/ UX design, web development services, or mobile app development services, Qaabil Digitals will be more than happy to help you. We work with top software developers, designers, and project managers. We tailor our services to suit your exact needs. We closely look at your company, listen to your story, and bring about the best ideas and solutions that can help you drive solid results. We don’t just produce work that works. We produce work that matters. Get a quote now Or Talk to us

Saturday 25 June 2011

Java program using nested if


import java.util.*;
class nestedif
{
public static void main (String arg[])
{
Scanner in = new Scanner (System.in);
int a,b,c,d;
System.out.print ("\n\t Enter first number = ");
a=in.nextInt();


System.out.print ("\n\t Enter second number = ");
b=in.nextInt();

System.out.print ("\n\t Enter third number = ");
c=in.nextInt();

 if (a<b)
{
if (a<c)
System.out.println ("\n\t First number is smallest ");
else
System.out.println ("\n\t First number is not smallest");
}
else if (b<a)
{
if (b<c)
System.out.println ("\n\t Second number is smallest ");
else
System.out.println ("\n\t Second number is not smallest ");
}
else
System.out.println ("\n\t Third number is smallest ");

}
}

Note: 
          In the above program, after entering the values, computer will check that either a is less than b or not. If it is than it will check the other if condition in its block. If it is true then it will show the message 
"First number is smallest" otherwise the statement associated with else will be executed and rest of the code will be bypassed.

No comments:

Post a Comment

Share