View Single Post
Join Date: Mar 2007
Posts: 30
Reputation: Ψmon is an unknown quantity at this point 
Solved Threads: 0
Ψmon Ψmon is offline Offline
Light Poster

Re: Average Program using an Array

 
0
  #3
Dec 2nd, 2008
What is not clear to me is: does the array have only positive numbers or are you finding the average of only positive numbers?

If the first, then Ancient Dragon has the con
If the second, you'd need to pull out only the positive numbers and divide by their count.

Perhaps ...
int a[6] = {2,-3, 4, -5, 6, -7};

int b[6] = new int[];
loop through a, placing positive values in b
then ...
The sum is 2+4+6 = 12
The average is 12/3 = 4
Reply With Quote