C Program to Swap Two Numbers Without Using Third(Temporary) Variable

In this program we will swap two numbers without using a third variable.

  1. //C Program to swap two numbers without using third(temporary) variable
  2. #include<stdio.h>
  3. int main()
  4. {
  5. int a, b;
  6. printf("Enter first number: ");
  7. scanf("%d", &a);
  8. printf("Enter second number: ");
  9. scanf("%d", &b);
  10. a = a + b;
  11. b = a - b;
  12. a = a - b;
  13. printf("Swapping of the numbers are= %d, %d", a, b);
  14. return 0;
  15. }

download android app

Popular C Examples


Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube