C Program to Swap Two Numbers Using Pointers

Pointers in C language is a variable that stores/points the address of another variable. In this Program we will swap to variable using pointers.

  1. //C program to swap two numbers using Pointers
  2. #include <stdio.h>
  3. int main()
  4. {
  5. int x, y, t;
  6. printf("Enter two integers\n");
  7. scanf("%d%d", &x, &y);
  8. printf("Before Swapping \nFirst integer = %d \nSecond integer = %d\n", x, y);
  9. t = x;
  10. x = y;
  11. y = t;
  12. printf("After Swapping \nFirst integer = %d \nSecond integer = %d\n", x, y);
  13. return 0;
  14. }

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