BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan

BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan (http://bzupages.com/index.php)
-   Visual Programming (http://bzupages.com/forumdisplay.php?f=237)
-   -   Program to find the Sum of all elements in an Array (By Sheraz) (http://bzupages.com/showthread.php?t=7187)

.BZU. 15-12-2009 11:00 PM

Program to find the Sum of all elements in an Array (By Sheraz)
 
Code:

  Module Module1
 
      Sub Main()
          Dim ar As Integer()
  Dim sum As Integer = 0
          ar = New Integer() {15, 8, 1, 6, 34, 7, 5, 342, 4, 7}
 
  For i = 0 To ar.GetUpperBound(0)
 
  sum = sum + ar(i)  ' or sum += ar(i)
 
  Next
 
          Console.Write("The sum of the elements of array is: {0}", sum)
          Console.ReadLine()
 
      End Sub
 
  End Module
 



All times are GMT +5. The time now is 06:56 PM.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.