#include <stdlib.h> int abs(int y);
abs
returns the absolute value of an integer.
abs
returns the absolute value of its argument.
abs
is implemented by a built-in function unless it is undefined by an
#undef
statement.
#include <stdlib.h> #include <stdio.h> #define BASELINE 32 main() { int range, temp; puts("The average temperature in NY in December is 32 degrees."); puts("Enter the average temperature in NC in December:"); scanf("%d", &temp); range = abs(BASELINE - temp); /* Calculate range. */ printf("The average temperatures differ by: %dn", range ); }
fabs
, labs
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.