ADVERTISEMENT
ADVERTISEMENT

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

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

Program/Source Code:

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 »



ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.