1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

I'm having trouble understanding this

Discussion in 'C++' started by Peter_morley, Sep 10, 2010.

  1. Peter_morley

    Peter_morley New Member

    Joined:
    Sep 10, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    I am trying to finish up my homework but I don't really understand the question


    Consider the array temps that the following statements define:

    typedef double WeekType[DAY_PER_WEEK];
    typedef WeekType YearType[WEEKS_PER_YEAR];
    YearType temps;

    temps[12] is a one-dimensional array of seven real numbers. Suppose that you want to compute the average of these seven numbers by calling a function average. Write the function average so that average(temps[12]) returns the desired average

    Here is a sample code that I've started with. Tell me if im on the right track. thanks

    int average(temps[12]){
    for(int index = 0, total = 0; index > 11; i++){
    total += temps[index];
    }
    return average = total/index;
    }
     

Share This Page