Output total rainfall and average temperature during the period

I got a loop running that will ask the user how many days of weather data they have. Then from there it asks what the rainfall and maximum temperature for the number of days the entered user entered in, but I'm not sure how to proceed in order to sum up the total rainfall and average the temperatures entered... Here's what I got so far...

#include<iostream>
using namespace std;
int main()
{
int a, b, c;
cout << "How many days of weather data do you have?" << endl;
cin >> a;
for (int i=1; i <= a; i++) {
cout << "What is the rainfall in inches for day " << i << "?" << endl;
cin >> b;
cout << "What was the maximum temperature in degrees fahrenheit for day " << i << "?" << endl;
cin >> c;
}

}
closed account (48T7M4Gy)
1. declare integer totals and initialise to zero
2. do the same with a counter variable
3. every time new data is input update totals and increment day counter
4. when all data is in calculate averages

Just like you would do on paper
Last edited on
closed account (48T7M4Gy)
PS a, b and c are not good variable names.
Topic archived. No new replies allowed.