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.
- //C program to swap two numbers using Pointers
- #include <stdio.h>
- int main()
- {
- int x, y, t;
-
- printf("Enter two integers\n");
- scanf("%d%d", &x, &y);
-
- printf("Before Swapping \nFirst integer = %d \nSecond integer = %d\n", x, y);
-
- t = x;
- x = y;
- y = t;
-
- printf("After Swapping \nFirst integer = %d \nSecond integer = %d\n", x, y);
-
- return 0;
- }
Output
