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