Suppose we have a large 2-Dimensional array with int values that have been read into it; the array actually has 250 rows and 100 columns; its name is temperatures. The display below shows a small part of the array, beginning with 37 in temperatures[0][0]. You may assume that all array positions are occupied.
37 15 6 -12 78 -7 43 . . .
16 34 -16 8 40 50 10 . . .
-4 17 19 20 -33 -2 -5 . . .
56 104 11 39 -10 55 101 . . .
77 71 -3 -11 88 62 78 . . .
. . . .
. .
. . . .
. .
How can we write a part of a C++ program that can accept a row and column specification from the keyboard and then display (in a 3x3 square) the nine temperatures that surround (and include) that position in the array. For example, if the specified row is 2 and the specified column is 4, the program should display the numbers surrounding temperatures[2][4], i.e. the -33 as; or if 3 and 1 are specified, the program should show
8 40 50 -4 17 19
20 -33 -2 56 104 11
39 -10 55
77 71 -3
Part II
Suppose that a survey has been taken in which thousands of people were asked a variety of questions regarding their television watching patterns. The information has been collected and is stored in the file watching.txt. Two of the questions asked were "How old are you?" and "How many hours per day do you watch TV on average?" The line below shows what an entry in the file looks like for one of the people surveyed:
103045 27 3 F 12 other values
Here 103045 is the person's
survey number, 27 is her age, 3 is the number of hours of TV, F is her
sex, 12 is the number of years of school, and the other values are of no
significance at the moment. How can we make a program that will produce
a frequency count for every possible combination of age and hours watched?
For example, we want to be able to determine how many people age 18 watch
TV 3 hours per day or 6 hours per day or 0 hours per day; and we want to
be able to determine how many people age 50 watch TV 2 hours per day or
8 hours per day.