I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
ComputingCStdlib.h

abs

Integer absolute value function
+ View other versions (4)

Interface

#include <stdlib.h>
int abs (int j)

Description

The abs function computes the absolute value of the integer j, denoted by \inline |j| and defined through:

Example 1

#include <stdio.h>
#include <stdlib.h>
 
int main()
{
  int a = -127;
  printf("|a| = %d\n", abs(a));
  return 0;
}

Output:
|a| = 127

Return Values

The abs function returns the absolute value.

Bugs

The absolute value of the most negative integer remains negative.