C program to swap two numbers without using temporary variable

C program to swap two numbers without using temporary variable

#include<stdio.h>
#include<conio.h>

void main()
{
int x,y;
clrscr();
printf(“Enter value of X: “);
scanf(“%d”,&x);
printf(“Enter value of y: “);
scanf(“%d”,&y);

if(x>y)
{
y=x-y;
x=x-y;
y=x+y;
}

else
if(y>x)
{
x=y-x;
y=y-x;
x=y+x;
}

printf(“nx=%d”,x);
printf(“ny=%d”,y);
getch();
}

Leave a Reply

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