VB.NET Questions/Answers-VB.NET operators (PartII)


VB.NET operators (PartII)

1. What is the output of the following VB.NET program?

Module Module1
 

    Sub Main()
   
      Dim x As Integer=10
      Dim y As Integer=15
      Dim mul As Integer
     mul= x * y
      Console.WriteLine("{0}*{1}={2}",x,y,mul)
      Console.ReadLine()

   End Sub

End Module

Check answer 2. What is the output of the following VB.NET program?


Module Module1
  

    Sub Main()
   
       Dim in_m, foot, yard, cent, meter As Double
       Console.Write("Enter a measurement in inches:")
       in_m=Double.Parse(Console.ReadLine())
       'using the FormatNumber function to format the number with 3 decimal places
       foot =FormatNumber(12 * in_m,3) '1 foot=12 inches
       yard =FormatNumber(36 * in_m,3) '1 yard=36 inches
       cent = FormatNumber(in_m / 2.54,3)  '1 inch=2.54 centimeters
       meter =FormatNumber(39.37 * in_m,3) '1 meter=39.37 inches

    Console.WriteLine("{0,-15}{1,-15}{2,-30}{3,-15}", foot &"feet", yard & "yards", cent & "centimeters", meter & "meters")

    Console.ReadLine()

   End Sub

End Module

 

Check answer 3. What is the output of the following VB.NET program?

Module Module1
 

    Sub Main()
   
      Dim x As Integer
      Dim f, m, l As Integer
      Console.Write("Enter 3 digit-integer number:")
      x=Integer.Parse(Console.ReadLine()) ;
      f = x / 100
      l = x Mod 10
      m = (x / 10) Mod 10

      Console.WriteLine("{0}{1}{2}", f & vbTab, m & vbTab, l)
      Console.WriteLine("{0}{1}", m & vbTab, l)
      Console.WriteLine("{0}", l)
      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.