Thursday 29 May 2014

program 10: print triangle(console)

program print a following pattern in console application.
                                    *
                                    **
                                    ***
                                    ****
                                    *****

-----------------------------------------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

No comments:

Post a Comment