How to find the average of positive numbers?
Loop throughout your array/list, count how many positive and how many negative numbers you have, add them sore them in a variable accordingly, positive in one number, negative in another number, say total_nr_of_positive_numbers for positive numbers, and total_nr_of_negative_numbers for negative numbers, than divide them at your total_number's number:
total_nr_of_positive_numbers/total_numbers
total_nr_of_negative_numbers/total_numbers
When you're looping solve the min/max problem as well. First, you set the first number as being min and max, than at each item from your array/list compare if is greater than your max, and smaller than your min, if so set the fields acordingly, if the number is greater than max, set max to that number, and the same for min, if the number is smaller than your min, set min to that number.
Also for the entire average, when you're looping, store in another variable the sum of all numbers, and than divide it to the total_numbers variable, like sum_of_all_numbers/total_numbers.
Lucaci Andrew
Practically a Master Poster
649 posts since Jan 2012
Reputation Points: 91
Solved Threads: 91
Skill Endorsements: 12