I need to find the difference in two numbers
Example ::::
3 && 6 = 3
-3 && 6 = 9
-3 && -6 = 3
3 && -6 = 9
Is there a standard math function that dose this, or do i need to write my own?
I need to find the difference in two numbers
Example ::::
3 && 6 = 3
-3 && 6 = 9
-3 && -6 = 3
3 && -6 = 9
Is there a standard math function that dose this, or do i need to write my own?
You can use abs() -
printf("%d\n%d\n%d\n%d\n",abs(3-6),abs((-3)-6),abs((-3)-(-6)),abs(3-(-6)));
zen
int difference(int a, int b)
{
return abs(a - b);
}
No standard function that I know of. Above is my version. abs() is a standard function that returns the absolute value of the integer in the ()s and is located in math.h. Code has not been tested.