abs - C math.h

C examples for math.h:abs

type

function

From

<cmath> 
<ctgmath> 
<math.h>

Description

Compute absolute value, Returns the absolute value of x: |x|.

Prototype

long double abs (long double x);
     double abs (double x);
      float abs (float x);
     double abs (T x);           

Parameters

Parameter Description
x Value whose absolute value is returned.

Return Value

The absolute value of x.

Demo Code

#include <iostream> // std::cout
#include <cmath> // std::abs

int main ()/* w  w w  .jav  a  2s  . c o m*/
{
  std::cout << "abs (3.1416) = " << std::abs (3.1416) << '\n';
  std::cout << "abs (-10.6) = " << std::abs (-10.6) << '\n';
  return 0;
}

Related Tutorials