Location: near Govt College of Science Multan Pakistan
Posts: 9,675
Contact Number: Removed
Program / Discipline: BSIT
Class Roll Number: 07-15
Find the Average of all elements in an Array VB Code (By Sheraz)
Module Module1 Sub Main() Dim ar As Integer() Dim sum As Integer = 0 Dim div As Integer Dim avg As Integer ar = New Integer() {15, 8, 1, 6, 34, 7, 5, 342, 4, 7} div = ar.Length 'Length property tells total # of elements in an array For i = 0 To ar.GetUpperBound(0) sum = sum + ar(i) ' or sum += ar(i) Next avg = sum / div Console.Write("The Average of the elements of array is: {0}", avg) Console.ReadLine() End Sub End Module
__________________
(¯`v´¯) `*.¸.*` ¸.*´¸.*´¨) ¸.*´¨) (¸.*´ (¸.Bzu Forum
Don't cry because it's over, smile because it happened
Best view in Firefox Almuslimeen.info | Cloud Computing | Dedicated server hosting Note: All trademarks and copyrights held by respective owners. We will take action against any copyright violation if it is proved to us.