 Home >>C Math Functions >C math fabs() function

# C math fabs() function

### C math fabs() function

The C math fabs() function is used to return the absolute value of any given number x. It takes a single argument (in double) and returns the absolute value of that number (also in double). This function is defined in <math.h> header file.

Syntax:
`double fabs(double x)`

### Parameter Values

x It is the floating point value.

Here is an example of fabs() function:
``````
#include <stdio.h>
#include <math.h>
int main ()
{
int a, b;
a = 1234;
b = -344;
printf("The absolute value of %d is %lf\n", a, fabs(a));
printf("The absolute value of %d is %lf\n", b, fabs(b));
return(0);
}
```
```
Output:
The absolute value of 1234 is 1234.000000
The absolute value of -344 is 344.000000
Example-2
``````
#include <stdio.h>
#include <math.h>
int main ()
{
int a, b;
a = 365.83;
b = -34.313;
printf("The absolute value of %d is %lf\n", a, fabs(a));
printf("The absolute value of %d is %lf\n", b, fabs(b));
return(0);
}
```
```
Output:
The absolute value of 365 is 365.000000
The absolute value of -34 is 34.000000