Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Midterm of Program Design (I) 2008/11/17 1. (15%) Write a program that reads a sequence of integers until a negative one being reached. The program then displays the minimum, the maximum and the average (in double) of the positive integers. (MinMaxAvg.c) Example of screen output Enter positive integers (-1 to end) : 15 11 3 -1 The maximum is 15 The minimum is 3 Their average is 9.66 2. (15%) Write a program that inputs a number, separates the number into its individual digits and prints the digits backward separated from one another.(ListDigitBackward.c) Example of screen output Input a number: 123456789 9 8 7 6 5 4 3 2 1 3. (15%) The following table shows telephone area codes in the state of Georgia along with the largest city in each area: Area code Major city 229 Albany 404 Atlanta 470 Atlanta 478 Macon 678 Atlanta 706 Columbus 762 Columbus 770 Atlanta 912 Savannah Write a program (AreaCode.c) with a switch statement whose controlling expression is the variable area_code. If the value of area_code is in the table, the switch statement will print the corresponding city name. Otherwise, the switch statement will display the message “Area code not recognized”. Be sure to make the switch statement as simple as possible. 4. (25%) Write a program that uses scanf to read two integers M (1 M 15) and N (1 N 10), and prints an M N table such that the mth row and the nth column of the table contains the value of m 2n1. Example of screen output Enter M : 6 Enter N : 4 m*2^0 m*2^1 m*2^2 m*2^3 m*2^4 1 2 4 8 16 2 4 8 16 32 3 6 12 24 48 4 8 16 32 64 5 10 20 40 80 6 12 24 48 96 5. (30%) A mail order house sells five different products whose retail prices are shown in the following table : Product number 1 2 3 4 5 Retail price $ 2.98 $ 4.50 $ 9.98 $ 4.49 $ 6.87 Write a program (Accounting.c) that reads a series of pairs of numbers as follows : a) Product number b) Quantity sold for one day Your program should calculate and display the total retail value of all products. Example of screen output Enter pairs of item numbers and quantities. Enter -1 for the item number to end input. 1 1 2 2 3 1 4 1 5 1 6 1 Invalid product code : Quantity : 1 1 1 6 -1 The total retail value was: $36.30