Multiplication table (use while) Learn programming Visual Basic (VB.net)

Lesson:

Flow Control


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:

Imports System
Public Class Exercise23
    Public Shared Sub Main()
        Dim num As Integer, multiplier As Integer = 1
        Console.Write("Insert a number to multiply: ")
        num = Convert.ToInt32(Console.ReadLine())

        While multiplier <= 10
            Console.WriteLine("{0} x {1} = {2}", num, multiplier, num * multiplier)
            multiplier += 1
        End While
    End Sub
End Class

Juan A. Ripoll - Systems Tutorials and Programming Courses ©  All rights reserved.  Legal Conditions.