VB.Net program to print the table of given number using Do Loop While

Here, we are going to learn how to print the table of given number using Do Loop While in VB.Net?
Submitted by Nidhi, on December 06, 2020 [Last updated : March 06, 2023]

Print the table of a number using Do Loop While in VB.Net

Here, we will read a number from the user and print the table of the given number using the Do Loop While loop on the console screen.

Program/Source Code:

The source code to print the table of given numbers using the Do Loop While loop is given below. The given program is compiled and executed successfully.

VB.Net code to print the table of given number using Do Loop While

'VB.Net program to print the table of given number 
'using "do loop while" loop.

Module Module1

    Sub Main()
        Dim count As Integer = 1
        Dim num As Integer = 0

        Console.Write("Enter number: ")
        num = Integer.Parse(Console.ReadLine())

        Do
            Console.Write("{0} ", num * count)
            count = count + 1
        Loop While (count <= 10)

        Console.WriteLine()
    End Sub
    
End Module

Output:

Enter number: 8
8 16 24 32 40 48 56 64 72 80
Press any key to continue . . .

Explanation:

In the above program, we created a module Module1 that contains a function Main(). In the Main(), we created two variables count and num, which are initialized with 1, 0 respectively.

Console.Write("Enter number: ")
num = Integer.Parse(Console.ReadLine())

Do
    Console.Write("{0} ", num * count)
    count = count + 1
Loop While (count <= 10)

In the above code, we read an integer number from the user and then print the table of the given number using the Do Loop While loop on the console screen.

VB.Net Basic Programs »





Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.