For example:
# include & ltstdlib.h & gt
# include & ltstdio.h & gt
int main(void)
{
int a =- 100;
int b = 200
Printf ("absolute value: %d\n",? ABS(a-b));
Returns 0;
}
The result is "absolute value:? 300"。
Extended data:
The number parameter of ABS function cannot be arbitrary, floating-point number or double-precision numerical expression. If number contains Null, it will return null. If it is an uninitialized variable, it returns 0. If the number parameter is not a number, but some characters, Null is returned.
C language has fabs function, and also seeks absolute value. The difference is that the parameters and return values of fabs function are real types. On a 32-bit computer, if you don't use system functions and conditional statements, you can use fabs function to get the absolute value.