VB.NET Questions Answers- VB.NET arrays (PartII)


VB.NET arrays (PartII)

1. What would be printed from the following VB.NET program?
Module Module1
 

   Sub Main()
  
     Dim arr() As Integer
    arr=New Integer(){1,3,5,7,9} 'initialize arr array
     Dim i As Integer
     For i=0 to 4 'output arr array
         Console.Write("{0}",arr(i)*arr(i) & vbTab)
     Next
    Console.ReadLine()

   End Sub

End Module

Check answer 2. What would be printed from the following VB.NET program?

Module Module1
 

   Sub Main()

     Dim arr() As Integer= New Integer(){1,3,5,7,9} 'initialize arr array
     Dim i As Integer
     For i=4 to 0 Step -1 'output arr array
        Console.Write("{0}",arr(i) & vbTab)
     Next
     Console.ReadLine()

   End Sub

End Module

Check answer 3.What would be printed from the following VB.NET program?

Module Module1
 

  Sub Main()

     Dim list1() As Integer=New Integer(){1,3,5,7,9} 'initialize list1 array
     Dim list2() As Integer=New Integer(5)
     Dim i As Integer
     For i=0 to 4
        list2(i)=list1(i)+1 'assign values to list2
     Next
     For i=0 to 4 'output list2
        Console.Write("{0}",list2(i) & vbTab)
     Next
     Console.ReadLine()

   End Sub

End Module

 Check answer 4. What would be printed from the following VB.NET program?
Module Module1
 

  Sub Main()
   
      Dim list() As Integer=New Integer(){1,2,3,4,5,6,7,8,9,10}
      Dim i As Integer
      For i=0 to 4
        'switching elements
          Dim temp As Integer=list(i)
          list(i)=list(9-i)
          list(9-i)=temp
       Next
    For i=0 to 9 'output list
       Console.Write("{0}",list(i) & vbTab)
    Next
    Console.ReadLine()

    End Sub

End Module

 Check answer


Comments




This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.