C# PROGRAM TO ADD TWO INTEGERS WITHOUT USING THIRD VARIABLE
C# Program To Add Two Numbers/Integers without using Third Variable :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
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(); } } } |
Sample Output:
For C Program : c program to add two numbers without using third variable
Nice post very helpful
dbakings