Thursday 29 May 2014

program 9: prime number

program to check the number is prime or not.

-----------------------------------------code---------------------------------------------------------

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim n, i, c As Integer
        n = TextBox1.Text
        For i = 1 To n
            If (n Mod i = 0) Then
                c = c + 1
            End If
        Next i
        If (c > 2) Then
            MsgBox("Number is not prime", , "Message")
            TextBox1.Text = ""
        Else
            MsgBox("Number is prime", , "Message")
            TextBox1.Text = ""
        End If
    End Sub
End Class

-----------------------------------------output----------------------------------------------------


umesh sohaliya
codestrew

umesh sohaliya
codestrew

No comments:

Post a Comment