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. }

Output


Output!