A function receives two integer pointers, int* a
and int* b
. Set the value of *a
to their sum, and *b
to their absolute difference.
There is no return value, and no return statement is needed.
I got the values for *a
but I'm unable to get the code for *b
.
#include <stdio.h>
void update(int *a,int *b);
int main() {
int a, b;
int *pa = &a, *pb = &b;
scanf("%d %d", &a, &b);
update(pa, pb);
printf("%d\n%d", a, b);
return 0;
}
void update(int *a,int *b)
{
*a+=*b;
*b=*a-*b;
}