HP C/iX Library Reference Manual (30026-90004)
102 Chapter5
HP C/iX Library Function Descriptions
abs
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 speciļ¬ed 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