View Single Post
  #1  
Old 15-12-2009, 11:05 PM
.BZU.'s Avatar
.BZU. .BZU. is offline


 
Join Date: Sep 2007
Location: near Govt College of Science Multan Pakistan
Posts: 9,693
Contact Number: Removed
Program / Discipline: BSIT
Class Roll Number: 07-15
.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute
Default Find Sum of Composite Numbers in an Array VB Code (By Sheraz)

Code:
 Module Module1
   
   Sub Main()
   Dim ar As Integer()
  Dim flag As Integer
   Dim sum As Integer = 0
  ar = New Integer() {15, 8, 1, 6, 34, 7, 5, 342, 4, 9}
   
   
   For i = 0 To ar.GetUpperBound(0)
              flag = 0
   For j = 2 To ar(i) / 2   'Divide by 2 because of Mathematics Rule
   If ar(i) Mod j = 0 Then
                      flag = 1
   Exit For 'To make Program more efficient (It is Optional)
   End If
   Next
   If flag = 1 Then
  sum = sum + ar(i)    ' or sum += ar(i)
  End If
   Next
   
          Console.WriteLine("The sum of composite numbers is: {0}", sum)
          Console.ReadLine()
   
   End Sub
   
  End Module
   
  

__________________
(¯`v´¯)
`*.¸.*`

¸.*´¸.*´¨) ¸.*´¨)
(¸.*´ (¸.
Bzu Forum

Don't cry because it's over, smile because it happened
Reply With Quote