VB.Net program to calculate the multiplication of two numbers using the '+' operator

Here, we are going to learn how to calculate the multiplication of two numbers using the + operator in VB.Net?
Submitted by Nidhi, on November 26, 2020 [Last updated : February 18, 2023]

Multiplying two numbers using '+' operator

Here, we will read two integer numbers from the user and calculate the multiplication of two numbers using the "+" operator.

VB.Net code to calculate the multiplication of two numbers using the '+' operator

The source code to calculate the multiplication of two numbers using the "+" operator is given below. The given program is compiled and executed successfully.

'VB.Net program to calculate the multiplication 
'of two numbers using the "+" operator.

Module Module1

    Sub Main()

        Dim num1 As Integer = 0
        Dim num2 As Integer = 0
        Dim mul As Integer = 0
        Dim count As Integer = 0

        Console.Write("Enter number1: ")
        num1 = Integer.Parse(Console.ReadLine())

        Console.Write("Enter number2: ")
        num2 = Integer.Parse(Console.ReadLine())

        mul = 0

        For count = 1 To num2 Step 1
            mul += num1
        Next

        Console.WriteLine("Multiplication is: {0}", mul)

    End Sub

End Module

Output:

Enter number1: 5
Enter number2: 4
Multiplication is: 20
Press any key to continue . . .

Explanation:

In the above program, we created a module Module1 that contains the Main() method. In the Main() method we created three local variables num1, num2, count, and mul that are initialized with 0. After that, we read the value of num1 and num2 from the user.

For count = 1 To num2 Step 1
    mul += num1
Next

In the above code, we add the value of the num1 value of num2 times using the for loop and then print the multiplication on the console screen.

VB.Net Basic Programs »





Comments and Discussions!

Load comments ↻





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