WAP to find largest among two numbers using scanner.

2 years ago
OOP Java

Compile code:

import java.util.Scanner;
public class Largestnumber1{
    public static void main(String args[])
    {
        int a, b, Largest;
        Scanner scan = new Scanner(System.in);
        System.out.print("Enter Two Number : ");
        a = scan.nextInt();
        b = scan.nextInt();
        if(a>b){
            Largest = a;}
        else{
            Largest = b;}
        System.out.print("Largest of Two Number is " +Largest);
    }
}

 

Output:

0
Dipti KC
Jan 8, 2023
More related questions

Questions Bank

View all Questions