View Single Post
Join Date: Oct 2008
Posts: 22
Reputation: Foe89 is an unknown quantity at this point 
Solved Threads: 0
Foe89 Foe89 is offline Offline
Newbie Poster

Re: Logic error, simple stat prog

 
0
  #3
Dec 1st, 2008
Originally Posted by ArkM View Post
Only getTotal code is correct. All three other fuctions are wrong.
1. getAverage: use getTotal to obtain a sum of all elements then divide sum by the number of elements!
2. getLargest and getSmallest: why double largest = array[100]; ?! No such element in the array at all. Start from array[0] value then loop from index 1.
lol I forgot to change the array back to 0, I was just messing around with things to see what would happen. And for the getAverage I can't seem to get it to work properly. Everytime I call getTotal I get some sort of syntax error. I'll tinker around with it again and see if i can get it to work as you've described.
Reply With Quote