11 Program to print 1 to 100 Prime Number Using For Loop in VB.NET

Code:

Module Module1

    Sub Main()

        Dim num, i As Integer
        Dim b As Boolean

        Console.WriteLine(" Prime Number From 1 to 100 = ")
     
        b = True

        For num = 1 To 100
            b = True
            For i = 2 To num - 1
                If num Mod i = 0 Then
                    b = False
                    GoTo break
                End If
            Next

break:
            If b Then
                Console.WriteLine(num)
            End If

        Next

        Console.ReadKey()

    End Sub

End Module





Output:  


Previous
Next Post »