Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
C Library
cassert (assert.h)
cctype (ctype.h)
cerrno (errno.h)
cfloat (float.h)
ciso646 (iso646.h)
climits (limits.h)
clocale (locale.h)
cmath (math.h)
csetjmp (setjmp.h)
csignal (signal.h)
cstdarg (stdarg.h)
cstddef (stddef.h)
cstdio (stdio.h)
cstdlib (stdlib.h)
cstring (string.h)
ctime (time.h)
cstdlib (stdlib.h)
functions:
abort
abs
atexit
atof
atoi
atol
bsearch
calloc
div
exit
free
getenv
labs
ldiv
malloc
mblen
mbstowcs
mbtowc
qsort
rand
realloc
srand
strtod
strtol
strtoul
system
wcstombs
wctomb
functions (non-standard):
itoa
macros:
EXIT_FAILURE
EXIT_SUCCESS
MB_CUR_MAX
NULL
RAND_MAX
types:
div_t
ldiv_t
size_t


labs

function
<cstdlib>
long int labs ( long int n );

Absolute value

Returns the absolute value of parameter n ( /n/ ).

Parameters

n
Integral value.

Return Value

The absolute value of n.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
/* labs example */
#include <stdio.h>
#include <stdlib.h>
int main ()
{
  long int n,m;
  n=labs(65537L);
  m=labs(-100000L);
  printf ("n=%ld\n",n);
  printf ("m=%ld\n",m);
  return 0;
}


Output:

n=65537
m=100000

See also