Home >>VB.Net Programs >VB.Net program to calculate the multiplication of two numbers using the '+' operator
Here, we can read two integer numbers from the user and use the "+" operator to determine the multiplication of two numbers.
Program :
Below is the source code for calculating the multiplication of two numbers using the '+' operator. The program given is compiled and successfully executed.
Example
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
Explanation:
We created a Module1 module in the program above that contains the Main() method. Three local variables num1, num2, count, and mul were generated in the Main() method which are initialized with 0. We then read the num1 and num2 values from the user after that.
For count = 1 To num2 Step 1 mul += num1 Next
In the above code, using the for loop, we add the num1 value to num2 times and then print the multiplication on the console screen.