You are viewing a single comment's thread. Return to all comments →
#include
void update(int *a, int *b) { int sum = *a + *b; int sub = (*a > *b) ? (*a - *b) : (*b - *a); *a = sum; *b = sub; }
int main() { int n1, n2; scanf("%d", &n1); scanf("%d", &n2); update(&n1, &n2); printf("%d\n%d", n1, n2); return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Pointers in C
You are viewing a single comment's thread. Return to all comments →
#include
void update(int *a, int *b) { int sum = *a + *b; int sub = (*a > *b) ? (*a - *b) : (*b - *a); *a = sum; *b = sub; }
int main() { int n1, n2; scanf("%d", &n1); scanf("%d", &n2); update(&n1, &n2); printf("%d\n%d", n1, n2); return 0; }