Alright, its a simple program to input 12 numbers in to an array corresponding to rain totals for each month and at the end it wants a total, an average, a high and a low.
I'm not able to get the 'high' amount, when I run the program it just gives me whatever number I put in the array first.
Code:#include <iostream> #include <iomanip> using namespace std; int main() { cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); const int months = 12; // number of months int rainamt[months]; // rain each month int count; int totalrain = 0; int averagerain; // Input the amount of rainfall for month for (count = 0; count < months; count++) { cout << "Enter the total rainfall for month " << (count + 1) << ": "; cin >> rainamt[count]; } { // Display contents of the array cout << "The rainfall amounts you entered are:"; for (count = 0; count < months; count++) cout << " " << rainamt[count]; cout << endl; } { for (count = 0; count < months; count++) totalrain += rainamt[count]; cout << "The total rainfall for the year is " << totalrain << " inches."; cout << endl; } { averagerain = totalrain / 12; cout << "The average rainfall for the year is " << averagerain << " inches per month."; cout << endl; } int highest; int highcount; highest = rainamt[0]; for (highcount = 1; highcount < months; highcount++) { if (rainamt[count] > highest) highest = rainamt[count]; } cout << "The highest rain amount in one month was " << highest << "."; cout << endl; return 0; }