The following program will swap two numbers by using third variable (Temporary Variable) #include <stdio.h> void main() { int a,b,c; printf("Enter first number: "); scanf("%d", &a); printf("Enter second number: "); scanf("%d",&b); c=a; a=b; b=c; printf("\nAfter swapping, a=%d b=%d",a,b); } Output
Leave a Comment