Exercise
Multiplication table (use while)
Objetive
Write a Visual Basic (VB.Net) program that prompts the user to enter a number and displays its multiplication table using a 'while' loop.
Code
' Importing necessary namespaces
Imports System
Public Class Program
Public Shared Sub Main()
' Declare a variable for the number
Console.Write("Enter a number: ")
Dim number As Integer = Convert.ToInt32(Console.ReadLine()) ' Read the number from the user
' Declare a variable to track the multiplier
Dim multiplier As Integer = 1
' Loop to display the multiplication table
While multiplier <= 10
' Display the result of the multiplication
Console.WriteLine("{0} x {1} = {2}", number, multiplier, number * multiplier)
multiplier += 1 ' Increment the multiplier for the next iteration
End While
End Sub
End Class