In c#, if wanted to find the largest values of 3 numbers, how would I do it? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

In c#, if wanted to find the largest values of 3 numbers, how would I do it?

I'm trying to insert 3 numbers and use the math library to find the largest of those numbers.

5th Sep 2017, 2:38 AM
Hakeem Thomas
Hakeem Thomas - avatar
1 Answer
+ 2
You don't need Math library to do it, simple algorithm will do, the general way would be:- (1) Read 3 numbers (e.g. num1, num2, num3) (2) Assume one of it is the largest (let's say num1) (3) Use relational operator to determine if:- (3.1) num2 is greater han num1 and num3, if yes num2 is the LARGEST (3.2) num3 is greater than num1 and num2, if yes num3 is the LARGEST. (4) Otherwise num1 would remain as the LARGEST. Can you take it from here?
5th Sep 2017, 3:01 AM
Zephyr Koo
Zephyr Koo - avatar