This website completely moved to new platform. For latest content, visit www.programmingposts.com

Search this Site

18 Aug 2013

VB.Net Program to ADD two INTEGERS witout using THIRD VARIABLE


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: