Midterm Examination (page 1) CS 141 Wednesday, October 23, 1996 This is a closed-book, closed-notes examination. There are six problems, each worth 16 points. 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. 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: Write a function called sum10 that has two integer parameters and returns true if the sum of the two numbers is larger than 10. Otherwise it returns false ------------------------------------------------------------------------------ Problem 2: Write a function called make0 that has two integer parameters. The function should set the smallest of the integer parameters to 0. ------------------------------------------------------------------------------ Problem 3: Write a function called diff that has two integer parameters, and returns the difference of the first input minus the second input if that difference is positive. Otherwise it returns 0. ------------------------------------------------------------------------------ Problem 4: Using the above functions, write a program that reads in two numbers. The program should print the difference of the two numbers if the difference is positive. Then the program should print a message saying whether the sum of the two numbers is larger than 10. Finally the program should set the smaller of the numbers to 0 and then print the numbers. ------------------------------------------------------------------------------ Problem 5: A. Write a function called smallest to read doubles until zero is read in and return the smallest of the doubles read in, except for zero. B. Using the function in part A, write a program to read in double until zero is read in and print out the smallest float read, except for zero. ------------------------------------------------------------------------------ Problem 6: A. Write a function called count10 to read integers until a negative is read in and return the number of integers smaller than 10 that were read in (excluding the negative). B. Using the function in part A, write a program to read in integers until a negative is read in and print out the number of itegers read in smaller than 10 (excluding the negative). ------------------------------------------------------------------------------