abs() Calculate Absolute Value of Integer
#include <stdlib.h> For function declarations
int abs(n);
int n; Integer value
abs() returns the absolute value of the integer 'n'.
Returns: The absolute value of 'n'.
-------------------------------- Example ---------------------------------
The following statements calculate the absolute values of -15, 0 and
33.
#include <math.h> /* Required for function declaration only */
main()
{
int x, y, z;
x = abs(-15); /* x = 15 */
y = abs(0); /* y = 0 */
z = abs(33); /* z = 33 */
}
Seealso:
This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster