Swapping Variable Using Third Variable






#include <stdio.h> #include<conio.h> int main() { int var1, var2, temp; printf("Enter two integers"); scanf("%d%d", &var1, &var2); printf("Before Swapping\nFirst variable = %d\nSecond variable = %d\n", var1, var2); temp = var1; var1 = var2; var2 = temp; printf("After Swapping\nFirst variable = %d\nSecond variable = %d\n", var1, var2); return 0; }


Output:-
Enter two integers2
3
Before Swapping
First variable = 2
Second variable = 3
After Swapping
First variable = 3
Second variable = 2

Comments

Popular posts from this blog

Calculate Factorial of a given no with help of Recursion

Get a string Using gets() function

Use of conditional Operators