Header Ad

Java program to compare two numbers using if else

In this tutorial, we are going to write a Java program to compare two numbers using if else in  Java Programming with practical program code and step-by-step full complete explanation.

Java program to compare two numbers using if else


Java program to compare two numbers using if-else.

 
public class CompareTwoNumbers 
{
	public static void main(String[] args) 
	{
		int num1 = 324;
		int num2 = 234;
		if(num1 > num2)
		{
			System.out.println(num1 + " is greater than " + num2);
		}
		else if(num1 < num2)
		{
			System.out.println(num1 + " is less than " + num2);
		}
		else
		{
			System.out.println(num1 + " is equal to " + num2);
		}
	}
}


Output

 
324 is greater than 234


Post a Comment

0 Comments