Swap Numbers

By Developgram - December 12, 2016

/*
Summary: Swap two numbers without using third number.
*/

#include <stdio.h>
int main()
{
 int a,b;

 printf("Enter a and b");
 scanf("%d",&a);
 scanf("%d",&b);

 printf("Before Swapping a=%d,b=%d",a,b);
 a=a+b;
 b=a-b;
 a=a-b;

 printf("After Swapping a=%d,b=%d",a,b);

 return 0;
}

  • Share:

You Might Also Like

0 comments