In: Computer Science
CORAL LANGUAGE ONLY
Write a program whose inputs are three integers, and whose outputs are the largest of the three values and the smallest of the three values. If the input is 7 15 3, the output is: largest: 15 smallest: 3 Your program should define and call two functions: Function LargestNumber(integer num1, integer num2, integer num3) returns integer largestNum Function SmallestNumber(integer num1, integer num2, integer num3) returns integer smallestNum The function LargestNumber should return the largest number of the three input values. The function SmallestNumber should return the smallest number of the three input values.
Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. If not, PLEASE let me know before you rate, I’ll help you fix whatever issues. Thanks
Note: Please maintain proper code spacing (indentation), just copy the code part and paste it in your compiler/IDE directly, no modifications required.
Function LargestNumber(integer num1, integer num2, integer num3) returns integer largestNum //if num1 is bigger than num2 and num3, setting it as largestNum if num1>=num2 and num1>=num3 largestNum=num1 //if num2 is bigger, setting it as largestNum elseif num2>=num1 and num2>=num3 largestNum=num2 //otherwise setting num2 as largestNum else largestNum=num3 Function SmallestNumber(integer num1, integer num2, integer num3) returns integer smallestNum //just like previous function, we find smallestNum if num1<=num2 and num1<=num3 smallestNum=num1 elseif num2<=num1 and num2<=num3 smallestNum=num2 else smallestNum=num3 Function Main() returns nothing //declaring integers integer num1 integer num2 integer num3 integer largest integer smallest //reading three values num1 = Get next input num2 = Get next input num3 = Get next input //finding largest and smallest largest=LargestNumber(num1,num2,num3) smallest=SmallestNumber(num1,num2,num3) //printing both Put "Largest: " to output Put largest to output Put "\nSmallest: " to output Put smallest to output //add a Put statement to print "\n" if your program //expects a newline at the end.
OUTPUT