C Program to Swap Two Numbers

To swap two numbers we will use another temporary variable to store the value of first number.

  1. //C Program to swap two numbers"
  2. #include<stdio.h>
  3. int main()
  4. {
  5. int a, b, c;
  6. printf("Enter first number: ");
  7. scanf("%d", &a);
  8. printf("Enter second number: ");
  9. scanf("%d", &b);
  10. c=a;
  11. a=b;
  12. b=c;
  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