Question
C++ - I'm having trouble understanding why the function isn't being recognized after being called. The function is to get the total of the array
C++ - I'm having trouble understanding why the function isn't being recognized after being called. The function is to get the total of the array totalMonthlyRainfall. I posted the text code below the image. Thank you for your help.
#include
using namespace std;
void monthlyRainfallInput(string[], double[], int);
double totalMonthlyRainfall(double, int);
int main() {
const int MONTHS = 12;
string months[MONTHS] = {"Jan", "Feb", "March", "Apr", "May", "June", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
double monthlyRainfall[MONTHS];
monthlyRainfallInput(months, monthlyRainfall, MONTHS );
totalMonthlyRainfall(monthlyRainfall, MONTHS);
return 0;
}
//Function that collects rainfall amount and puts into array
void monthlyRainfallInput(string months[], double monthlyRainfall[], int MONTHS){
for (int x = 0 ; x
cout
cin >> monthlyRainfall[x];
}
for (int x = 0 ; x
cout
}
}
//Function that calculates total rainfall
double totalMonthlyRainfall(double monthlyRainfall[], int MONTHS){
int total = 0;
for (int x = 0; x
total = total + monthlyRainfall[x];
}
return total;
}
12 #includeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started