Pages

Monday, 29 January 2018

C# PROGRAM TO ADD TWO INTEGERS WITHOUT USING THIRD VARIABLE

C# PROGRAM TO ADD TWO INTEGERS WITHOUT USING THIRD VARIABLE
using System;

namespace CsharpPrograms
{
    class Program
    {
        static void Main(string[] args)
        {

            int x,y;
            Console.WriteLine(">>> PROGRAM TO ADD TWO NUMBERS WITHOUT USING THIRD VARIABLE <<< ");
            Console.Write("\n Enter the first number to be added: ");
            x=Convert.ToInt32(Console.ReadLine());         // taking x value from keyboard
            Console.Write("\n Enter the second number to be added: ");
            y = Convert.ToInt32(Console.ReadLine());         // taking y value from keyboard
            x = x + y;     /*assining the value of sum of x and y to x*/

          Console.WriteLine("\n The sum of two numbers is: "+x);    /*printing the sum.*/
          Console.ReadLine();
        }
    }

}