Pages

Search This Blog

Non Static Array Input and Output Declaration


Module Declaration

    Sub Main()
        Dim n, i As Integer
        Console.Write("Enter the number of elements: ")
        n = CInt(Console.ReadLine())
        Dim arr(n) As Integer
        For i = 0 To n - 1
            Console.Write("Enter the " + (i + 1).ToString() + "th element: ")
            arr(i) = CInt(Console.ReadLine())
        Next
        Console.WriteLine("Array contains...")
        For i = 0 To n - 1
            Console.Write(arr(i) & "  ")
        Next
        Console.ReadLine()
    End Sub

End Module

No comments:

Post a Comment