Sunday, 1 November 2015

Java Program to print greatest of two numbers


Program:

import java.io.*;
import java.util.*;
class greater
{
public static void main(String[ ] args) {
System.out.println("Enter two values: ");
Scanner s = new Scanner(System.in);
int a = s.nextInt();
int b = s.nextInt();
if(a>b)
System.out.println(a + " is Greater than " + b);
else
System.out.println(b + " is Greater than " + a);
}
}

Input/Output:

Enter two values:
5
6
6 is Greater than 5

0 comments:

Post a Comment