int abs ( int n );
long abs ( long n ); |
<cstdlib> |
Absolute value
Returns the absolute value of parameter n ( /n/ ).
Parameters
- n
- Integral value.
Return Value
The absolute value of n.
Portability
In C, only the
int version exists.
Example
/* abs example */
#include <stdio.h>
#include <stdlib.h>
int main ()
{
int n,m;
n=abs(23);
m=abs(-11);
printf ("n=%d\n",n);
printf ("m=%d\n",m);
return 0;
}
|
Output:
See also
labs | Absolute value (function) |
fabs | Compute absolute value (function) |
div | Integral division (function) |