A program that will ask for 3 numbers and arranged the numbers from smallest to largest | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

A program that will ask for 3 numbers and arranged the numbers from smallest to largest

How to code this

29th Oct 2021, 4:29 AM
CHRISTINE MINDAJAO
3 Answers
0
Hi Christine, this is quite basic and can be done with the use of conditional statements. The actual code would depend on what programming language you will be using, but the overall flow goes like this: Assuming you have integers x, y and z, if (x < y && x < z) { // x is smallest, print x if (y < z) // print y then z else // print z then y } // if x is not the smallest, the smallest value must be among y and z else if (y < z) { // y is smallest, print y if (x < z) // print x then z else // print z then x } // if x and y is not the smallest, then z is the smallest else { // print z if (x < y) // print x then y else // print y then x }
29th Oct 2021, 4:48 AM
Fermi
Fermi - avatar
0
OK I'll try one.. Thanks
29th Oct 2021, 5:32 AM
CHRISTINE MINDAJAO
0
I'm using C programming course
29th Oct 2021, 5:33 AM
CHRISTINE MINDAJAO