Math, asked by suneetashukla55, 3 months ago

write a program in java to enter 3 numbers and print the smallest number​

Answers

Answered by Sly01
34
  • import java.util.Scanner;
  • public class SmallestNumberExample5.
  • {
  • public static void main(String args[])
  • {
  • int num1, num2, num3;
  • System.out.println("Enter three integers: ");
  • Scanner in = new Scanner(System.in);

Answered by palakchordiya123
3

Answer:

import java.util.Scanner;

public class SmallestNumberExample1

{

public static void main(String[] args)

{

int a, b, c, smallest, temp;

//object of the Scanner class

Scanner sc = new Scanner(System.in);

//reading input from the user

System.out.println("Enter the first number:");

a = sc.nextInt();

System.out.println("Enter the second number:");

b = sc.nextInt();

System.out.println("Enter the third number:");

c = sc.nextInt();

//comparing a and b and storing the smallest number in a temp variable

temp=a<b?a:b;

//comparing the temp variable with c and storing the result in the variable names smallest

smallest=c<temp?c:temp;

//prints the smallest number

System.out.println("The smallest number is: "+smallest);

}

}

Hope it helps u ☺️

mark as brainlist please ❤️

Similar questions