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