pc-ip-07.c (710B)
1 /* 2 * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 05 Jan 2026 3 * Repo: https://github.com/notamitgamer/bsc 4 * License: MIT 5 */ 6 7 /* 8 * Question 7: 9 * Write a program to swap two numbers using pointers using user-defined function. 10 */ 11 12 #include <stdio.h> 13 14 void swap(int *, int *); 15 16 int main() 17 { 18 int a, b; 19 printf("Enter two number: "); 20 scanf("%d %d", &a, &b); 21 printf("\nBefore Swap: "); 22 printf("\nA = %d, Loc: %p", a, &a); 23 printf("\nB = %d, Loc: %p", b, &b); 24 swap(&a, &b); 25 printf("\nAfter Swap: "); 26 printf("\nA = %d, Loc: %p", a, &a); 27 printf("\nB = %d, Loc: %p", b, &b); 28 return 0; 29 } 30 31 void swap(int *a, int *b) 32 { 33 int temp = *a; 34 *a = *b; 35 *b = temp; 36 }