Write a program to input three numbers and display the second greatest number. Use Math functions only.Sample input: 33, 44, 55 Sample output: second greatest number = 44
Answers
Answered by
0
Explanation:
FOR I IN RANGE(3):
X = INT(INPUT("ENTER A NO"))
V = L.APPEND(X)
FOR I IN L:
IF I NOT IN L2:
K = L2.APPEND(I)
Z = L2.SORT(REVERSE=TRUE)
PRINT("SECOND GREATEST NO IS",L2[0])
*MARK ME AS BRAINLY
Answered by
2
Question:-
Write a program to input 3 numbers and display the second largest among them using only Math functions.
Program:-
import java.util.*;
class Min
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter first number: ");
int a=sc.nextInt();
System.out.print("Enter second number: ");
int b=sc.nextInt();
System.out.print("Enter third number: ");
int c=sc.nextInt();
int m=Math.min(Math.min(Math.max(a,b),Math.max(b,c)),Math.max(a,c));
System.out.println("Second Largest Number is: "+m);
}
}
Similar questions