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/)
-   Visual Programming (http://bzupages.com/237-visual-programming/)
-   -   Display the Prime Numbers of an Array VB Code (By Sheraz) (http://bzupages.com/f237/display-prime-numbers-array-vb-code-sheraz-7191/)

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

Display the Prime Numbers of an Array VB Code (By Sheraz)
 
Code:

  Module Module1
 
      Sub Main()
          Dim ar As Integer()
  Dim flag As Integer
          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 efficien(It is ptional)
                  End If
              Next
              If flag = 0 Then
                  Console.WriteLine("The number {0} is Prime", ar(i))
              End If
          Next
 
 
          Console.ReadLine()
 
      End Sub
 
  End Module

 



All times are GMT +5. The time now is 11:57 AM.

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