write a programmer-defined function named descend() that receives three integer numbers. Then, the function prints the numbers in descending order. A sample run of the program might look as follows: Enter three numbers: 1 -2 4 Descending order: 4 1 -2
It could have the following algorithm ``` function swab (a: int , b: int) temp = a a = b b = temp return a, b function decend print 'Enter three numbers:' n1= input an integer n2= input an integer if n1 < n2 swab(n1, n2) n3= input an integer if n3 > n1 swab(n3, n1) swab(n1, n2) else if n3 > n2 swab(n3, n2) print n3, n2, n1 ```
Oh, and end with a return if needed
I've never heard of any programming language with functions which can return 2 results.. This should work: ``` function descend(a, b, c) number first, second, third //declare 3 variables if a >= b then { first = a second = b } else { first = b second = a } if c >= first then { third = second second = first first = c } else if c >= second then { third = second second = c } else { third = c } Output ("Descending order : ", first, second, third) ```
Join our real-time social learning platform and learn together with your friends!