Suppose a school wanted to keep track of how many students had each mark. Here is a program that would create an array for the total number of students with each mark. It will initialize all the values to 0. Since this array is relatively large we will not be using the init approach to initialize the array.
|
|
Which test do you want to enter a result for? Enter a negative number to end. 2 What did you get on test #2? 86 Which test do you want to enter a result for? Enter a negative number to end. 4 What did you get on test #4? 91 Which test do you want to enter a result for? Enter a negative number to end. 5 What did you get on test #5? 95 Which test do you want to enter a result for? Enter a negative number to end. 8 That is not a valid test, try again. Which test do you want to enter a result for? Enter a negative number to end. 1 What did you get on test #1? 79 Which test do you want to enter a result for? Enter a negative number to end. -1 Here are your current test results: Test 1 2 3 4 5 6 ------------------------------ 79 86 0 91 95 0 |
|