C Program to show swap of two numbers without using third variable

#include
void main()
{
 int a,b;
 printf("enter 1st no.");
 scanf("%d",&a);
 printf("enter 2nd no.");
 scanf("%d",&b);
 a=a+b;
 b=a-b;
 a=a-b;
 printf("%d is 1st no. and %d is 2nd no.\n",a,b);
}
Output:



C Program to show swap of two numbers without using third variable C Program to show swap of two numbers without using third variable Reviewed by Prashant Sengar on December 22, 2017 Rating: 5

No comments:

Powered by Blogger.