C#: Program to swap two numbers
Swap Two Numbers
Write a C# Sharp program to swap two numbers.
C# Sharp: swapping two variables
The act of swapping two variables refers to mutually exchanging the values of the variables. Generall, this is done with the data in memory.
Using a temporary variable :
The simplest method to swap two variables is to use a third temporary variable :
define swap(x, y) temp := x x := y y := temp

Sample Solution:
C# Sharp Code:
Sample Output:
Input the First Number : 2 Input the Second Number : 5 After Swapping : First Number : 5 Second Number : 2
Flowchart:

C# Sharp Code Editor:
Previous: Write a C# Sharp program to print the result of the specified operations.
Next: Write a C# Sharp program to print the output of multiplication of three numbers which will be entered by the user.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics