ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 28 Apr 2017 My Price 8.00

Modify the program to add a function

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]);         
      }      
   }
}

Answers

(11)
Status NEW Posted 28 Apr 2017 03:04 AM My Price 8.00

-----------

Attachments

file 1493351395-Solutions file 2.docx preview (51 words )
H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly -----------onl-----------ine----------- an-----------d g-----------ive----------- yo-----------u e-----------xac-----------t f-----------ile----------- an-----------d t-----------he -----------sam-----------e f-----------ile----------- is----------- al-----------so -----------sen-----------t t-----------o y-----------our----------- em-----------ail----------- th-----------at -----------is -----------reg-----------ist-----------ere-----------d o-----------n -----------THI-----------S W-----------EBS-----------ITE-----------. ----------- Th-----------ank----------- yo-----------u -----------
Not Rated(0)