Home Show/Hide Menu
Bluej Programs
➜ Test-paper-IT-10
➜ Suggestion Paper, Class-12

bluej Programs

2.Write a program to enter 2 numbers. Print the smaller between these two.

import java.util.*;
class smaller
{
    void main()
    {
        Scanner sc=new Scanner(System.in);
        int m,n;
        System.out.println("Enter 1st number:");
        m=sc.nextInt();
        System.out.println("Enter 2nd number:");
        n=sc.nextInt();
        if(m>n)
        System.out.println("Smaller is:"+n);
        else
        System.out.println("Smaller is:"+m);
    }
}


Output:
Enter 1st number:
23
Enter 2nd number:
34
Smaller is:23

 
ADVERTISEMENT