Swap using a third variable Program in C
WAP that swaps values of two variables using a third variable.
#include<stdio.h>
/*5. WAP that swaps values of two variables using a third variable. */
void main()
{
int a,b,temp;
printf("Enter a=");
scanf("%d",&a);
printf("Enter b=");
scanf("%d",&b);
temp=a;
a=b;
b=temp;
printf("\nAfter swapping");
printf("\na=%d",a);
printf("\nb=%d",b);
}
Output:
Enter a=10 Enter b=20 After swapping a=20 b=10c language tutorial learn c language study c language