Exercise
Multiplication table
Objetive
Write a Visual Basic (VB.Net) program to ask the user for a number and display its multiplication table, like this:
Please enter a number:
5
The multiplication table for 5 is:
5 x 1 = 5
5 x 2 = 10
5 x 3 = 15
...
5 x 10 = 50
Code
' Import the System namespace to use Console class
Imports System
Public Class Program
' Main subroutine, entry point of the program
Public Shared Sub Main()
' Prompt the user to enter a number
Console.Write("Please enter a number: ")
Dim number As Integer = Convert.ToInt32(Console.ReadLine())
' Display the multiplication table for the entered number
Console.WriteLine("The multiplication table for " & number & " is:")
For i As Integer = 1 To 10
Dim result As Integer = number * i
Console.WriteLine(number & " x " & i & " = " & result)
Next
End Sub
End Class