Problem: Create
a program to swap to integer number without using third variable.
Process: Addition
of these two numbers and addition store in first number. Subtraction of first number to second number.
Solution :
using System;
namespace SwapNumber
{
class Program
{
static void Main(string[] args)
{
int firtsNumber = 10, secondNumber = 20;
Console.WriteLine("First Number = {0} and Second Number = {1}",
firtsNumber, secondNumber);
firtsNumber += secondNumber;
secondNumber = firtsNumber - secondNumber;
firtsNumber = firtsNumber - secondNumber;
Console.WriteLine("First Number = {0} and Second Number = {1}",
firtsNumber, secondNumber);
Console.ReadLine();
}
}
}
Output :