Tuesday, September 22, 2015

PRINT STAR PATTERN IN VB.NET USING NESTED FOR LOOP


Above pattern print program is given below -

 Dim row, col, noofrow, noofcol, colspace, temp As Integer
        noofrow = 10 : noofcol = noofrow : temp = 1
        For row = 1 To noofrow
            For colspace = noofcol - row To 1 Step -1
                Console.Write(" ")
            Next
            For col = 1 To temp
                Console.Write("*")
            Next
            Console.Write(vbNewLine)
            temp += 2
        Next

        Dim row1, col1, noofrow1, colspace1, temp1 As Integer
        noofrow1 = 10 : temp1 = (noofrow1 * 2) - 3
        For row1 = 1 To noofrow1
            For colspace1 = 1 To row1
                Console.Write(" ")
            Next
            For col1 = 1 To temp1
                Console.Write("*")
            Next
            Console.Write(vbNewLine)
            temp1 -= 2
        Next

0 comments:

Post a Comment