C PROGRAMMING

write a c program to swap two variables withour using third variable

 

#include <stdio.h>
main()
{
int x, y;
printf("Enter first numbern");
scanf("%d",&x);
printf("Enter second numbern");
scanf("%d",&y);
printf("Before Swapping: x = %d y = %dn", x, y);
x = x + y;
y = x - y;
x = x - y;
printf("After Swapping: x = %d y = %d", x, y);
getch();
}
Show More

Related Articles

Leave a Reply

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

Back to top button