Write a C Program to Swap two numbers using third variable

Write a C Program to Swap two numbers using third variable

Here is the C Program to swap two numbers using third variable.

#include<stdio.h>
#include<conio.h>
int main()
{            int a,b,c;
              clrscr();
              printf(“Enter value of A:”);
              scanf(“%d”,&a);
              printf(“Enter value of B:”);
              scanf(“%d”,&b);
             printf(“Before Swap:”);
             printf(“\nA=%d\nB=%d”,a,b);
             c=a;
             a=b;
             b=c;
             printf(“After Swap:”);
             printf(“\nA=%d\nB=%d”,a,b);
             return 0;
}
Output

You may also like...

Leave a Reply