abs
int  abs ( int n );
math.h
stdlib.h
  cplusplus.com  

Return absolute value of integer parameter.
  The absolute value corresponding to the integer parameter n is returned ( /n/ ).

Parameters.

n
Integer value.

Return Value.
  The absolute value of n.

Portability.
  Defined in ANSI-C.
  In addition to the prototype already specified for this function, ANSI-C++ standard incorporates an overloaded version:
    long abs (long n );
  with the same functionality as labs.

Example.

/* abs example */
#include <stdio.h>
#include <math.h>

main ()
{
  int n,m;
  n=abs(23);
  m=abs(-11);
  printf ("n=%d\n",n);
  printf ("m=%d\n",m);
  return 0;
}
Output:
 n=23
 m=11

See also.
  labs, fabs


© The C++ Resources Network, 2000