![]() |
| ||
| Getting the sum and average help! Hey, I am trying to create the sum of my values contained in MyArray variable simultaneously while assigning the values in the same loop. Afterwards, I want to find the average of the numbers after the loop finishes. Problem: When I compute the numbers, I keep getting the same sum and average for whatever number I put in. How do I fix this problem? Also, do you see any other errors in my code?
|
| ||
| Re: Getting the sum and average help! I think it is suppose to be MyArray(I) = I + 10 because I need it to be 10+ more than the integer. |
| ||
| Re: Getting the sum and average help! You mention you get the same sum and average no matter which number you put in. Which line of code are you referring to when you say "for whatever number I put in". Secondly, the following line Average = Sum / MyArray.GetUpperBound(0)should be Average = Sum / (MyArray.GetUpperBound(0) + 1)The upperBound function returns the largest index, which is one less of the number of items in the array. |
| All times are GMT -4. The time now is 1:56 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC