C program to print the swapping of two numbers using the third variable

C program to print the swapping of two numbers using the third variable. This program will help you to find how the number changes in c programming to interchange the number which are initialized before the program execute and how it prints the another value in c program

int main() 
int a, b, temp;
printf("Enter a number ");
scanf("%d", &a);
printf("Enter b number ");
scanf("%d", &b);
temp = a;
a = b;
b = temp;
printf("After swapping");
printf("\na = %d\n", a);
printf("b = %d", b);
return 0;



Enter a number 45

Enter b number 3

After swapping a = 3 b = 45

How to execute swapping program using temp variable in c

The first variable’s value is assigned to the temp variable. The first variable’s value is then allocated to the second variable. Finally, second receives the temp (which contains the starting value of first ). The swapping operation is now complete.

What is temporary variable in c program

A temporary variable is a variable in computer programming that has a brief lifetime and is used to retain data that will be removed quickly or before it can be stored in a more permanent memory location. Because it is temporary, it is normally specified as a local variable (a variable with only a local scope).