Fall 2008: Pretest for cis1068 Name:_____________________________________ List and describe (1 sentence) any computer programming courses you have taken. If you took a course at Temple, please indicate the course, semester you took it, and your grade in that course. List any mathematics courses you have taken at Temple and the grade you received. Also indicate the result of your mathematics placement exam and the mathematics course you are currently taking if any. Problem Solving questions (each question specifies the Points associated to that question – Total = 100 points) 1.(7) You were able to drive 300 miles in your car using a tank of gas (15 gallons). What is your gas mileage and how many gallons of gas will it take you to drive 2600 miles? Show your formulas. 2.(7) A house is situated in a lot that is 100 by 80 feet. The house size is 40 by 50. You can mow grass at the rate of 40 square feet a minute. How long will it take to mow the lawn around the house? 3.(6) Function min(x, y) finds the smaller of its arguments x and y. Write a mathematical expression using function min that finds the smallest of x, y, and z. 4.(10) Assume you need to find the shortest ribbon in a collection of ribbons, but you can only compare 2 ribbons at a time. Write an algorithm for doing this. 5.(10) Write a computer program for solving 4. Assume the ribbon lengths are stored in an array named ribbonLength. Computer and Programming Questions 1. (3) How many distinct configurations of 1s and 0s are possible when using 8 bits? (If using 2 bits, the configurations are four: 00,01,10,11). 2. (2) What is a byte? 3. (5) What is a compiler? 4. (2) What is a microsecond? 5. (3) Declare an integer variable x whose initial value is 7. 6. (6) Indicate which of the following assignments is legal (you can assume all variables are initialized integers) x = x + 3 / 2 x - 1 = 4 + 5 * 3 x = 7 # 6 6.(4)What value is stored in y by the statements below if a is 3, b is 4, and c is 3.5? Explain what these statements do in general. (for example, find the average of a, b, and c) if a > b then y = a; else y = b; if c > y then y = c; 7.(8)What does the following loop store in x and z if the sequence of values read into y is 1, 3, 5, 7, and 0 ? x = 0; z = 1; read a value into y; while y is not equal to 0 begin /* loop */ x = x + y; z = z * y; read a value into y; end; /* loop */ 8.(5) Say in English what is collected in x and z by the code In question 7. 9. (13) Assume you have two array, a and b, of the same size. Write a program fragment to store all the values currently in array a into array b in the reverse order. When finished, the first value in array b will be the last value in a; the last value in array b will be the first value in a, and so on. 10.(9) Assume you are given the function skip which has as an integer n as its parameter. Function skip will print out n stars followed by '+'. For example, if n is 3, function skip will display the line ***+. Write a program fragment that uses function skip to print out m lines: line 1, line 2, … , line m such that the kth line contains k star s followed by '+'. Do not write the function skip.