Algorithm:-
(1)Start
(2)take two number from user and store in two variable
(3)multiply these two number and store in first variable
(4)divide first variable by second variable and store value in second variable
(5)divide the first variable by second variable and store value in first variable
(6)print the changed value of a and b
(7)stop
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestApplicationOnly
{
class Program
{
static void Main(string[] args)
{
int a, b;
Console.Write("\nEnter the First Number : ");
a = Convert.ToInt32 (Console.ReadLine());
Console.Write("\nEnter the Second Number : ");
b = Convert.ToInt32 (Console.ReadLine());
Console.WriteLine("Before swapping a= " + a + " b= " + b);
a = a * b;
b = a / b;
a = a / b;
/*or you can also use
{a = a + b;
b = a - b;
a = a - b; }*/
Console.Write("After swapping a= " + a + " b= " + b);
Console.ReadKey();
}
}
}
output:-
Enter the First Number : 5
Enter the Second Number: 8
Before swapping a= 5 b= 8
After swapping a= 8 b= 5
0 टिप्पणियाँ