We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- C
- Introduction
- Pointers in C
- Discussions
Pointers in C
Pointers in C
Sort by
recency
|
636 Discussions
|
Please Login in order to post a comment
**
include
void update(int *a,int *b) { int sum = *a + *b; int diff = *a - *b; if (diff < 0) { diff = -diff; } *a = sum; *b = diff; }
int main() { int a, b; int *pa = &a, *pb = &b;
} **
4 5
#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; }