Modify the rain program in L isting 10.7 so that it does the calculations using pointers instead of subscripts. (You still have to declare and initialize the array.)
10.7
/* rain.c — finds yearly totals yearly average and monthlyaverage for several years of rainfall data */#include
printf( YEAR RAINFALL (inches)n);for (year = 0 total = 0; year < YEARS; year++){ // for each year sum rainfall for each monthfor (month = 0 subtot = 0; month < MONTHS; month++)//subtot += rain[year][month];subtot += *(*(rain + year) + month);printf(%5d %15.1fn 2000 + year subtot);total += subtot; // total for all years}printf(nThe yearly average is %.1f inches.nntotal / YEARS);printf(MONTHLY AVERAGES:nn);printf( Jan Feb Mar Apr May Jun Jul Aug Sep Oct );printf( Nov Decn);
for (month = 0; month < MONTHS; month++){ // for each month sum rainfall over yearsfor (year = 0 subtot = 0; year < YEARS; year++)//subtot += rain[year][month];subtot += *(*(rain + year) + month);printf(%4.1f subtot / YEARS);}printf(n);
return 0;}