Exam 1 CS 141 Wednesday, March 4, 1998 This is a closed-book, closed-notes examination. There are four problems. Do not spend too much time on any problem. Read them all through first and solve them in the order that allows you to make the most progress. For each of the problems, you need to write a program or a function. You do not need to write comments, function prototypes, or include statements. You can also assume that string, bool, true, and false have already been defined if you need them. Your program doesn't have to be fancy or user-friendly. You should make it as simple as possible, as long as it does what is required. ------------------------------------------------------------------------------ Problem 1 (30 points): A. Write a function called monus that takes two integers as parameters. The function should return the difference of the first integer minus the second if the first integer is larger than the second, otherwise it should return 0. B. Using the function of part A, write a program to read in two integers and print the difference of the first integer minus the second if the first integer is larger than the second, otherwise print 0. ------------------------------------------------------------------------------ Problem 2 (20 points): Suppose I have already written a function called regurg that takes an integer as parameter and returns true if the integer is reguritatable (a word I just made up), and false otherwise. Using my function, write a function called regurg_both that takes an integer as parameter, and returns true if that integer and twice that integer are both regurgitatable, otherwise it returns false. ------------------------------------------------------------------------------ Problem 3 (20 points): Write a function with two integer variables as input parameters. The function should check which of its inputs is largest, and set both of those integer variables to the largest value of the two. ------------------------------------------------------------------------------ Problem 4 (30 points): A. Write a function called print_between that takes two integers as parameters. If the first integer is smaller than or equal to the second, the function should print out all the integers from the first to the second, with one space between each integer, and go to a new line at the end. If the first integer is larger than the second, an error message should be printed. B. Using the function from part A, write a function called print_number_square that prints the following: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 ------------------------------------------------------------------------------