google search

Popular Posts


Welcome to BCA Notes

>>>>>>>>>>>>>>>>

Visitors

Search This Blog

Blogger templates

Visitor Map


Thursday, 29 January 2015

Printing multidimensional array to make a pattern



Printing multidimensional array to make a pattern
Source code:-

Module Module1

    Sub Main()
        Dim arr(3, 3) As Integer
        Dim j, i As Integer
        Console.Write("Enter a nine number:")
        For i = 0 To 2
            For j = 0 To 2
                Console.Write("[{0}] [{1}]  ", i, j)
                arr(i, j) = Convert.ToInt32(Console.ReadLine)
            Next
        Next

        For i = 0 To 2
            For j = 0 To 2
                Console.Write("{0} ", arr(i, j))
            Next
            Console.WriteLine()
        Next
        'Console.WriteLine("array length is {0}", arr.Length)
        Console.ReadKey()

    End Sub

End Module

Output:-


Source code:-
Module Module1
    Sub Main()
        Dim arr(3, 3), i, j As Integer
        For i = 0 To 2

            For j = 0 To 2
                Console.WriteLine("Enter [{0}][{1}]", i, j)
                arr(i, j) = Convert.ToInt32(Console.ReadLine)
            Next
        Next
        For i = 0 To 2

            For j = 0 To 2
                Console.WriteLine("Enter [{0}][{1}]", i, j)
                Console.WriteLine("{0}", arr(i, j))
            Next
        Next
        Console.ReadKey()
    End Sub
End Module
Output:-

0 comments:

Post a Comment