Array Help

Array Help. 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.7Listing 10.7ÿÿ Theÿ rain.cÿ Program ÿ /* rain.cÿ — finds yearly totals, yearly average, and monthlyÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ average for several years of rainfall data */ÿ #include ÿ #define MONTHS 12ÿÿÿ // number of months in a yearÿ #define YEARSÿÿ 5ÿÿÿ // number of years of dataÿ int main(void)ÿ {ÿÿ // initializing rainfall data for 2010 – 2014ÿÿÿÿÿ const float rain[YEARS][MONTHS] =ÿÿÿÿÿ {ÿÿÿÿÿÿÿÿÿ {4.3,4.3,4.3,3.0,2.0,1.2,0.2,0.2,0.4,2.4,3.5,6.6},ÿÿÿÿÿÿÿÿÿ {8.5,8.2,1.2,1.6,2.4,0.0,5.2,0.9,0.3,0.9,1.4,7.3},ÿÿÿÿÿÿÿÿÿ {9.1,8.5,6.7,4.3,2.1,0.8,0.2,0.2,1.1,2.3,6.1,8.4},ÿÿÿÿÿÿÿÿÿ {7.2,9.9,8.4,3.3,1.2,0.8,0.4,0.0,0.6,1.7,4.3,6.2},ÿÿÿÿÿÿÿÿÿ {7.6,5.6,3.8,2.8,3.8,0.2,0.0,0.0,0.0,1.3,2.6,5.2}ÿÿÿÿÿ };ÿÿÿÿÿ int year, month;ÿÿÿÿÿ float subtot, total;ÿÿÿÿÿÿÿ printf(” YEARÿÿÿ RAINFALLÿ (inches)n”);ÿÿÿÿÿ for (year = 0, total = 0; year < YEARS; year++)ÿÿÿÿÿ {ÿÿÿÿÿÿÿÿÿÿÿÿ // for each year, sum rainfall for each monthÿÿÿÿÿÿÿÿÿ for (month = 0, subtot = 0; month < MONTHS; month++)ÿÿÿÿÿÿÿÿÿÿÿÿÿ subtot +=ÿ rain[year][month];ÿÿÿÿÿÿÿÿÿ printf("%5d %15.1fn", 2010 + year, subtot);ÿÿÿÿÿÿÿÿÿ total += subtot; // total for all yearsÿÿÿÿÿÿ }ÿÿÿÿÿ printf("nThe yearly average is %.1f inches.nn",ÿÿÿÿÿÿÿÿÿÿÿÿÿ total/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 yearsÿÿÿÿÿÿÿÿÿ for (year = 0, subtot =0; year < YEARS; year++)ÿÿÿÿÿÿÿÿÿÿÿÿÿ subtot += rain[year][month];ÿÿÿÿÿÿÿÿÿ printf("%4.1f ", subtot/YEARS);ÿÿÿÿÿ }ÿÿÿÿÿ printf("n");ÿÿÿÿÿÿÿ return 0;ÿ }

Array Help


15% off for this assignment.

Our Prices Start at $11.99. As Our First Client, Use Coupon Code GET15 to claim 15% Discount This Month!!

Why US?

100% Confidentiality

Information about customers is confidential and never disclosed to third parties.

Timely Delivery

No missed deadlines – 97% of assignments are completed in time.

Original Writing

We complete all papers from scratch. You can get a plagiarism report.

Money Back

If you are convinced that our writer has not followed your requirements, feel free to ask for a refund.