PROGRAM TO SWAP TWO NUMBERS WITHOUT USING THIRD VARIABLE

/*PROGRAM TO SWAP TWO NUMBERS WITHOUT USING THIRD VARIABLE*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf(“Enter any two numbers: “);
scanf(“%d%d”,&a,&b);
printf(“Before swapping numbers were: \n”);
printf(“\ta=%d and b=%d\n”,a,b);
a=a+b;
b=a-b;
a=a-b;
printf(“After swapping numbers are: \n”);
printf(“\ta=%d and b=%d”,a,b);
getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *