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

    Sep 10, 2010
    Likes Received:
    Trophy Points:
    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