WAP to find smallest among three numbers using scanner.

1 year ago
OOP Java

Compile code:

import java.util.Scanner;

public class Smallestamongthreenumbers{

    public static void main(String args[])

    {

        int a, b,c,Smallest;

        Scanner scan = new Scanner(System.in);

        System.out.print("Enter Three Number : ");

        a = scan.nextInt();

        b = scan.nextInt();

        c=scan.nextInt();

        if(a<b&&a<c){

            Smallest = a;}

        else if(b<a&&b<c){

            Smallest = b;}

        else{

            Smallest =c;

        }

        System.out.print("Smallest of Three Number is " +Smallest);

    }

}

 

Output:

0
Dipti KC
Jan 8, 2023
More related questions

Questions Bank

View all Questions