- 1
A program that will ask for 3 numbers and arranged the numbers from smallest to largest
How to code this
3 ответов
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
}
0
OK I'll try one.. Thanks
0
I'm using C programming course