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. Solution: int monus(int x, int y) { if (x > y) return x-y; else 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. Solution: void main() { int num1, num2; cout << "Give me two numbers: "; cin >> num1 >> num2; cout << monus(num1,num2); } ------------------------------------------------------------------------------ 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. Solution: bool regurg_both(int x) { if (regurg(x) && regurg(2*x)) return true; else return 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. Solution: void set_largest(int &x, int &y) { if (x > y) y = x; else x = y; } ------------------------------------------------------------------------------ Problem 4 (30 points): A. Write a function called print_between that takes two integers as paramters. 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. Solution: void print_between(int x, int y) { int i; if (x <= y) { for (i = x; i <= y; i++) cout << i << " " cout << "\n"; } else cout << "Error\n"; } 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 Solution: void print_number_square() { int i; for (i = 1; i < 100; i += 5); print_between(i,i+4); } ------------------------------------------------------------------------------