using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace value
{
class SWAP
{
static void Main(string[] args)
{
int x;
int y;
Console.WriteLine("To SWAP the two numbers");
Console.WriteLine("enter the first number");
x = int.Parse( Console.ReadLine());
Console.WriteLine("enter the second number");
y = int.Parse(Console.ReadLine());
Console.WriteLine("two number are {0} {1}",x,y);
//SWAP Logic
x = x+y;
y = x-y;
x= x-y;
Console.WriteLine("Swaped number are {0} {1}", x,y);
Console.ReadLine();
}
}
}
Enter the first number=2
Enter the second number =3
output:- 3 2
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace value
{
class SWAP
{
static void Main(string[] args)
{
int x;
int y;
Console.WriteLine("To SWAP the two numbers");
Console.WriteLine("enter the first number");
x = int.Parse( Console.ReadLine());
Console.WriteLine("enter the second number");
y = int.Parse(Console.ReadLine());
Console.WriteLine("two number are {0} {1}",x,y);
//SWAP Logic
x = x+y;
y = x-y;
x= x-y;
Console.WriteLine("Swaped number are {0} {1}", x,y);
Console.ReadLine();
}
}
}
Enter the first number=2
Enter the second number =3
output:- 3 2