Swapping of two numbers/characters can be done by different ways. Generally all people know swapping using a temporary variable.
In this post i will tell you how to swap two variables in 3 different ways, and which algorithm is efficient to swap the variables.
Here all the below examples are shown in C code(executed in linux environment with gcc compiler).
Method 1:
In this post i will tell you how to swap two variables in 3 different ways, and which algorithm is efficient to swap the variables.
Here all the below examples are shown in C code(executed in linux environment with gcc compiler).
Method 1:
- Swapping using a temporary variable: