# Logic?

• 01-31-2003
Kurious
Logic?
I am a student trying to complete some homework.
The program is supposed to demonstrate the use of an array.
The program is supposed to input the rainfall amounts for twelve months. It is then supposed to calulate the total amount, the average, and then tell the months with the highest and lowest amounts. I'm not sure what way I should use to compare the amounts to find the highest and lowest amounts.
• 01-31-2003
Hammer
>>I'm not sure what way I should use to compare the amounts to find the highest and lowest amounts.
Create 2 variables to hold the 2 extreme numbers, highest and lowest. As you read in the new data, compare each one to the highest/lowest variables, if they are more extreme, update the highest/lowest variable accordingly.

Use < and > within an if statement to compare values.

Post some code when you have troubles.
• 01-31-2003
Travis Dane
*sniff sniff* I smell homework AGAIN:mad:

Well try this:

Code:

``` #include <iostream> using namespace std; int waterfall_rain_amount[12]; int main(void) { int a; int b; for(a=0;a<=11;a=a+1) { cin >> water_fall_rain_amount[a]; } for(a=0;a<=11;a=a+1) { b+=water_fall_rain_amount[a]; } cout << "Amount of rain is" << b/12 << endl; return 0; }```
• 01-31-2003
pode
use a var like int temp[] to store the needed stuff
then u can check the temps for lowest-highest values?!