Largest numvber of three numer using nested if else | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Largest numvber of three numer using nested if else

31st Dec 2022, 5:06 AM
Nikhil Singh
Nikhil Singh - avatar
2 Answers
+ 2
What have you tried so far? Which part of this task is giving you trouble? You would have the three numbers in variables such as a, b, c Make a 4th variable to store the max You can write comparisons in "if" statements, and compare two variables at a time. When you figure which of the two is bigger, compare it to the third one. Then assign the result to your max variable.
31st Dec 2022, 7:54 AM
Tibor Santa
Tibor Santa - avatar
0
Can you explain what you are having troubles with? I think a nested if/else is not needed. You could define a max function which takes in two integers and returns the larger of the two. You can daisy chain calls to your max function then to find the largest of three: max(x, max(y, z));
31st Dec 2022, 6:38 PM
DinoBambino