0

Find Second Largest Number

Write a java program four integer numbers from command line argument. Display and find second largest number using conditional operator. Try this question and send me the answer in the comments. Change the my code.

3rd Sep 2024, 4:18 AM
Dhruv Asodariya
Dhruv Asodariya - avatar
2 Answers
+ 3
Attempt?
3rd Sep 2024, 4:58 AM
A͢J
A͢J - avatar
0
1. create two variables, mx1 and mx2. assign the first input to mx1, the second input to mx2. 2. if mx2>mx1, swap them. 3. if the 3rd input is > mx2, assign it to mx2. 4. again, swap if mx2>mx1. 5. repeat steps 3 and 4 for the next inputs. what you want will be stored in mx2.
4th Sep 2024, 1:17 AM
Bob_Li
Bob_Li - avatar