Hello, I’m working on this task:
- Write a program that swaps the values of two int variables x and y, using a third variable to temporarily hold one value. Initial values for x and y are already given. The output of the program should be “x is {x} and y is {y}” after you swap the values. Use string interpolation.
Here is my code:
class SwapTheValues
{
static void Main()
{
int temp =x;
x =y;
y=temp;
Console.WriteLine("x is {x} and y is {y}");
}
}
Can anyone please help me to solve it?