![]() Chapter Contents |
![]() Previous |
![]() Next |
| abs |
| Portability: | ISO/ANSI C conforming, UNIX compatible |
| SYNOPSIS | |
| DESCRIPTION | |
| RETURN VALUE | |
| IMPLEMENTATION | |
| EXAMPLE | |
| RELATED FUNCTIONS | |
| SEE ALSO |
| SYNOPSIS |
#include <stdlib.h> int abs(int y);
| DESCRIPTION |
abs
returns the absolute value of an integer.
| RETURN VALUE |
abs
returns the absolute value of its argument.
| IMPLEMENTATION |
abs
is implemented by a built-in function unless it is undefined by an
#undef
statement.
| EXAMPLE |
#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: %d\n", range );
}
| RELATED FUNCTIONS |
| SEE ALSO |
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.