#include <stdio.h> void swap_pointers(int **p1, int **p2) { // Your logic here int *add = *p1; // printf("p1=%x p2=%x add=%x **p1=%d **p2=%d \n",*p1,*p2,add,**p1,**p2); *p1 = *p2; // printf("p1=%x p2=%x add=%x **p1=%d **p2=%d \n",*p1,*p2,add,**p1,**p2); *p2 = add; // printf("p1=%x p2=%x add=%x **p1=%d **p2=%d \n",*p1,*p2,add,**p1,**p2); } int main() { int a, b; scanf("%d %d", &a, &b); int *p1 = &a; int *p2 = &b; // printf("p1=%x p2=%x \n", p1, p2); swap_pointers(&p1, &p2); printf("%d %d", *p1, *p2); return 0; }
Test Cases
Test Results
Input
10 20
Expected Output
20 10