The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Can someone help me figure out this code using ideone? I cannot figure it out and I've already tried several times. need it ASAP thank you!
Â
Modify the program to add a function to sum the rainfall for each year. (Hint: you need to sum for each year. You can do this using a looping structure). Support your experimentation with screen captures of executing the new code
Â
#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];
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 timen");
  }
  printf("Please try the Precipitation program again. n");
  return 0;
}
// function to inputdata
void inputdata() {
 /* variable definition: */
 float Rain=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;        Â
     }
  }
}
// Function to printdata
void printdata(){
// Print data
  printf ("yeart montht rainn");
  for (int year=0;year < NUMYEARS; year++) {
     for (int month=0; month< NUMMONTHS; month++) {
         printf("%st %st %5.2fn", years[year],months[month],Raindata[year][month]);        Â
     }     Â
  }
}
-----------