Write a program to find the smallest of three numbers using if else if in java
Answers
Answered by
2
Answer:
Program:-
import java.util.*;
public class Smallest
{
public static void main(String args[ ])
{
Scanner in=new Scanner(System.in);
int a,b,c;
System.out.println("Enter the numbers");
a=in.nextInt();
b=in.nextInt();
c=in.nextInt();
if(a<b&&a<c)
{
System.out.println("The smallest number="+a);
}
else if(b<a&&b<c)
{
System.out.println("The smallest number="+b);
}
else if(c<a&&c<b)
{
System.out.println("The smallest number="+c);
}
}
}
Answered by
1
Answer:
public class smallest
{
public void small(int a, int b, int c)
{
int min=0;
if(a<b&&a<c)
min=a;
elseif(b<c)
min=b;
else
min=c;
System.out.println(min+"is the smallest number");
}
}
Similar questions
Math,
1 month ago
Social Sciences,
4 months ago
Hindi,
4 months ago
Social Sciences,
10 months ago
Math,
10 months ago
Math,
10 months ago