Write a program that three non- equal -equal integers and return the smallest? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Write a program that three non- equal -equal integers and return the smallest?

Use n_way else If statement

18th Jun 2018, 4:52 PM
CHERUYOT SIMON
CHERUYOT SIMON - avatar
2 Answers
0
private void GetSmallest(params int[] numbers){ return numbers.Sort()[0]; } This may be a little cheaty but it works. I am writing this on my phone let me know if this produces an exception.
18th Jun 2018, 6:25 PM
John
John - avatar
0
if a > b currSmallest= b else currSmallest= a if currSmallest > c currSmallest= c return currSmallest
18th Jun 2018, 6:55 PM
KrOW
KrOW - avatar