Bill said:
No, you're not even remotely close.
Try to do a little more desk work, i.e. looking at your code and
thinking
about it on your own, before you embarrass yourself like this in
public.
Well I googled some sites and tried to look for average calculation
examples. I found a couple. But they were all run from main and nothing
like what I want. So I tried to find something and messed it up. So I
thought I'd try usenet.
Bill
Bill,
Maybe you should try to start with some pseudo code...
Something like this (this is a made up syntax that I just came up with,
just for you):
Function : Average
Purpose : To average a passed in array of doubles and return the result
Inputs : array of doubles
number of values in the array
Outputs : Returns the computed average of the array
Pseudo code :
Function average ( double : values array ; int : numValues )
: return double
begin
Create a double called sum and initialize it to 0.0
loop through all of the values from 0 to numValues - 1 using
iterator called "index"
set sum = sum + values [ index ]
end loop ;
set return value to sum divided by numValues
end function average
Play computer, run through your Pseudo code by hand to make sure it will
function as expected, and THEN translate it to C code after you
understand what it is doing.
Hope this helps,
Joe