Monday, September 21, 2015

PRINT STAR PATTERN IN VB.NET USING NESTED FOR LOOP


Above pattern print program is given below -

Dim row, col, col1, col2, noofrow, noofcol, colspace As Integer
        noofrow = 20 : noofcol = noofrow : colspace = (noofrow * 2) - 2
        For row = 1 To noofrow
            For col = 1 To row
                Console.Write("*")
            Next
            For col1 = 1 To colspace
                Console.Write(" ")
            Next
            For col2 = 1 To row
                Console.Write("*")
            Next
            Console.Write(vbNewLine)
            colspace -= 2
        Next

0 comments:

Post a Comment