Prime number sample program using vb.net.
Public Sub PrintPrimeNumber()
Dim Num As Long
Dim NN As Long
Dim IsPrime As Boolean
For Num = 2 To 100
IsPrime = True
For NN = 2 To Int(Num / 2)
If Num Mod NN = 0 Then
IsPrime = False
Exit For
End If
Next
If IsPrime Then
Response.Write(Num & " is a prime number!" & "<br>")
End If
Next
End Sub
Odd number sample program using vb.net
Public Sub PrintOddNumber()
For number As Integer = 0 To 100
If (number Mod 2) = 1 Then
Response.Write(number & ", ")
End If
Next
End Sub
Even number sample program using vb.net
Public Sub PrintEvenNumber()
For number As Integer = 0 To 100
If (number Mod 2) = 0 Then
Response.Write(number & ", ")
End If
Next
End Sub
0 comments:
Post a Comment