abs [ HP C/iX Library Reference Manual ] MPE/iX 5.0 Documentation
HP C/iX Library Reference Manual
abs
Computes the absolute value of an integer argument.
Syntax
#include <stdlib.h>
int abs (int x);
Parameters
x An integer value whose absolute value is to be computed.
Return Values
x The absolute value of the integer specified in x.
Example
The following program calculates integer absolute values until a zero is
entered from the keyboard:
#include <stdlib.h>
#include <stdio.h>
main(void)
{
int value;
do
{
printf("Enter value: ");
scanf("%d", &value);
if (value == 0)
exit (0);
printf("Absolute value of %d is %d.\n", value, abs(value));
}
while (value !=0);
}
See Also
fabs(), labs(), floor(), ANSI C 4.10.6.1, POSIX.1 8.1
MPE/iX 5.0 Documentation