Need to write a function with 2 floats that make the first argument "a - b" and the second one "b - a", then print the 2 with .2 precision.
Compiles but output is not correct.
Can anyone tell me why? and maybe suggest me a book with a good pointers chapter? My slides are confusing.
This is my code.
Code:
#include <stdio.h>
float diff_abs(float*, float*);
float diff_abs(float *a, float *b)
{
*a = *a - *b;
*b = *b - *a;
}
int main(void)
{
float x;
float y;
scanf("%f", &x);
scanf("%f", &y);
diff_abs(&x,&y);
printf("%.2f\n", x);
printf("%.2f", y);
return 0;
}
Thanks in advance.