The ouput is so long so i have trim the image define

Info icon This preview shows pages 6–11. Sign up to view the full content.

the ouput is so long so i have trim the image. #define NUMMONTHS 12 #define NUMYEARS 5 #include <stdio.h> // function prototypes void inputdata(); void printdata(); // Global variables // These are available to all functions float Raindata[NUMYEARS][NUMMONTHS]; float WindSpeed[NUMYEARS][NUMMONTHS]; char years[NUMYEARS][5] = {"2011","2012","2013","2014","2015"}; char months[NUMMONTHS][12] ={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}; int main () { char enterData = 'y'; printf("Do you want to input Precipatation data? (y for yes)\n"); scanf("%c",&enterData); if (enterData == 'y') { // Call Function to Input data inputdata(); // Call Function to display data
Image of page 6

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

printdata(); } else { printf("No data was input at this time\n"); } printf("Please try the Precipitation program again. \n"); return 0; } // function to inputdata void inputdata() { /* variable definition: */ float Rain=1.0; float Wind=1.0; // Input Data for (int year=0;year < NUMYEARS; year++) { for (int month=0; month< NUMMONTHS; month++) { printf("Enter rain for %d, %d:\n", year+1, month+1); scanf("%f",&Rain); Raindata[year][month]=Rain; } } for (int year=0;year < NUMYEARS; year++) { for (int month=0; month< NUMMONTHS; month++) { printf("Enter WindSpeed for %d, %d:(mph)\n", year+1, month+1); scanf("%f",&Wind); WindSpeed[year][month]=Wind; } } } // Function to printdata void printdata(){ // Print data printf ("year\t month\t rain\t wind\n "); for (int year=0;year < NUMYEARS; year++) { for (int month=0; month< NUMMONTHS; month++) { printf("%s\t %s\t %5.2f\t %5.2f\n", years[year],months[month],Raindata[year][month],WindSpeed[year][month]); } } printf ("sum the rainfall for each year\n"); printf ("year\t rain(sum)\n"); float sumRain = 0.0; for (int year=0;year < NUMYEARS; year++) { for (int month=0; month< NUMMONTHS; month++) {    sumRain += Raindata[year][month]; } printf("%s\t %5.2f\n", years[year],sumRain); } }
Image of page 7
Output:
Image of page 8

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

5. Question:  What happens if you change the NUMMONTHS and NUMYEARS definitions to other values? Be sure  to use both lower and higher values. Describe and implement fixes for any issues if errors results. Support your  experimentation with screen captures of executing the new code. The following code is associated with this question: #define NUMMONTHS 12 #define NUMYEARS 5 #include <stdio.h> // function prototypes void inputdata(); void printdata(); // Global variables // These are available to all functions float Raindata[NUMYEARS][NUMMONTHS]; float WindSpeed[NUMYEARS][NUMMONTHS]; char years[NUMYEARS][5] = {"2011","2012","2013","2014","2015"}; char months[NUMMONTHS][12] ={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}; int main () { char enterData = 'y'; printf("Do you want to input Precipatation data? (y for yes)\n"); scanf("%c",&enterData); if (enterData == 'y') { // Call Function to Input data inputdata(); // Call Function to display data printdata(); } else { printf("No data was input at this time\n"); } printf("Please try the Precipitation program again. \n"); return 0;
Image of page 9
} // function to inputdata void inputdata() { /* variable definition: */ float Rain=1.0;
Image of page 10

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Image of page 11
This is the end of the preview. Sign up to access the rest of the document.
  • Fall '09
  • Rain, scanf, enter, windspeed

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern