Thread: Logic?

  1. #1


    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.

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    >>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.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User
    Join Date
    Sep 2002
    *sniff sniff* I smell homework AGAIN

    Well try this:

    #include <iostream>
    using namespace std;
    int waterfall_rain_amount[12];
    int main(void)
    int a;
    int b;
    cin >> water_fall_rain_amount[a];
    cout << "Amount of rain is" << b/12 << endl;
    return 0;

  4. #4
    Registered User
    Join Date
    Dec 2001
    use a var like int temp[] to store the needed stuff
    then u can check the temps for lowest-highest values?!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Digital Logic
    By strokebow in forum Tech Board
    Replies: 3
    Last Post: 12-09-2006, 01:05 PM
  2. Logic
    By LordBronz in forum C++ Programming
    Replies: 6
    Last Post: 05-23-2006, 05:41 PM
  3. Actors, cues, event based logic.
    By Shamino in forum Game Programming
    Replies: 2
    Last Post: 04-27-2006, 10:58 PM
  4. Circular Logic
    By DavidP in forum A Brief History of
    Replies: 1
    Last Post: 10-15-2001, 08:10 PM