//Swapping of 2 Numbers without using 3rd number
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace cs3
{
class Program
{
static void Main(string[] args)
{
int x,y;
Console.WriteLine("Enter any 2 Numbers");
x = int.Parse(Console.ReadLine());
y = int.Parse(Console.ReadLine());
Console.WriteLine("Before Swapping the Numbers are");
Console.Write("First Number:" + x);
Console.Write("\tSecond Number:" + y);
x = x + y;
y = x - y;
x = x - y;
Console.WriteLine("\n\nAfter Swapping the Numbers are");
Console.Write("First Number:" + x);
Console.Write("\tSecond Number:" + y);
Console.ReadLine();
}
}
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.