using System;
class abc
{
double a, b;
public void swap()
{
Console.WriteLine("Program for swapping : ");
Console.WriteLine("Numbers before swapping : ");
Console.WriteLine("Enter first no : ");
a = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Enter second no : ");
b = Convert.ToDouble(Console.ReadLine());
a = a + b;
b = a - b;
a = a - b;
Console.WriteLine("Numbers after swapping : ");
Console.WriteLine("First no is : " + a);
Console.WriteLine("Second no is : " + b);
Console.ReadKey();
}
}
class aa
{
public static void Main(string[] args)
{
abc a = new abc();
a.swap();
}
}
Output:
class abc
{
double a, b;
public void swap()
{
Console.WriteLine("Program for swapping : ");
Console.WriteLine("Numbers before swapping : ");
Console.WriteLine("Enter first no : ");
a = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Enter second no : ");
b = Convert.ToDouble(Console.ReadLine());
a = a + b;
b = a - b;
a = a - b;
Console.WriteLine("Numbers after swapping : ");
Console.WriteLine("First no is : " + a);
Console.WriteLine("Second no is : " + b);
Console.ReadKey();
}
}
class aa
{
public static void Main(string[] args)
{
abc a = new abc();
a.swap();
}
}
Output:
No comments :
Post a Comment