Thought Sharing

Wednesday, December 9, 2009

Write a program in VB to calculate average of 10 numbers using arrays

Private Sub Command1_Click()
Dim n(10) As Integer
Dim sum As Long
Dim Avg As Single
sum = 0
For i = 1 To 10
n(i) = InputBox("Enter number")
Next
For i = 1 To 10
sum = sum + n(i)
Next
Print sum
Avg = sum / 10
Print Avg
End Sub