Module Module1

    Sub Main()
        Dim x As Integer, y As Integer
        Console.WriteLine("*** www.ProgrammingPosts.blogspot.com ***")
        Console.WriteLine(">>> VB.NET PROGRAM TO ADD TWO NUMBERS WITHOUT USING THIRD VARIABLE <<< ")
        'vblf gets the cursor to next linein console
        Console.Write(vbLf & " Enter the first number to be added: ")
        ' taking x value from keyboard
        x = Convert.ToInt32(Console.ReadLine())

        Console.Write(vbLf & " Enter the second number to be added: ")
        ' taking y value from keyboard
        y = Convert.ToInt32(Console.ReadLine())

        'assining the value of sum of x and y to x
        x = x + y

        'printing the sum.
        Console.WriteLine(vbLf & " The sum of two numbers is: " & x)
        Console.ReadLine()
    End Sub

End Module

 

Sample Output:

VB.Net Add Two Number Without Third

 

 

Leave a Reply

Your email address will not be published.