programming-examples/c-sharp/_Basic/C# Program to Swap 2 Numbers.cs

35 lines
826 B
C#
Raw Normal View History

2019-11-15 12:59:38 +01:00
/*
* C# Program to Swap two Numbers
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Program
{
class Program
{
static void Main(string[] args)
{
int num1, num2, temp;
Console.Write("\nEnter the First Number : ");
num1 = int.Parse(Console.ReadLine());
Console.Write("\nEnter the Second Number : ");
num2 = int.Parse(Console.ReadLine());
temp = num1;
num1 = num2;
num2 = temp;
Console.Write("\nAfter Swapping : ");
Console.Write("\nFirst Number : "+num1);
Console.Write("\nSecond Number : "+num2);
Console.Read();
}
}
}
/*
Enter the First Number : 23
Enter the Second Number : 25
After Swapping :
First Number : 25
Second Number : 23