P056.c (717B)
1 /* 2 * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 12 Dec 2025 3 * Repo: https://github.com/notamitgamer/bsc 4 * License: MIT 5 */ 6 7 /* WAP to swap the value of a and b using user defined method. */ 8 9 // This code has not been compiled. 10 // If you find any issues, please create a new issue on GitHub regarding them. 11 // Go to this link to create a new issue: https://github.com/notamitgamer/bsc/issues 12 13 #include <stdio.h> 14 15 void swap(int *a, int *b) 16 { 17 int temp = *a; 18 *a = *b; 19 *b = temp; 20 } 21 22 int main() 23 { 24 int a, b; 25 printf("Enter A and B: "); 26 scanf("%d %d", &a, &b); 27 printf("\nBefore swap A: %d, B: %d", a, b); 28 swap(&a, &b); 29 printf("\nAfter swap A: %d, B: %d", a, b); 30 return 0; 31 }