Im suppose to write a program that accepts five input values and stores them into an array. The program should then display the average of the five numbers. Finally, the program should display all the numbers in the array that are larger than the average of the five numbers. I understand everything except how to display all the numbers in the array that are larger than the average of the five numbers. I cannot seem to figure this part out. Any help would be thankful.

In pseudo code, you could create a listbox then do

for each item in the array
    if item > average then
        add item to the listbox
    end if
next

Do you know how to use a listbox? If not then you could also use a multiline textbox.

first declare array variable so that you can store inputted value to this, so declare array variable

dim arrx(4) as double

getting input through input box and store its values to an array variable.

for i=0 to 4
arrx(i)=inputbox("enter value")
sum_of_array=sum_of_array+arrx(i)
next

calculate the average , for this write as follow :

avg=sum_of_array/5 

I understand everything except how to display all the numbers in the array that are larger than the average of the five numbers

its simple , just traverse an array with for each

for each item in arrx
    if item>avg then
        print item 'you can also use listbox , textbox etc.
    end if
next

hope this explaination helps you . . .

@Reverend Sir,
Sorry for that. I forgot about this . In future i'll consider this before posting .

thanx sir.

Edited 3 Years Ago by rishif2

This article has been dead for over six months. Start a new discussion instead.