The C fabs function is one of the C Math Functions, used to return the absolute positive number of a given value or a specified expression. The syntax of the fabs in C Programming is
double fabs(double number);
C fabs Function Example
The C math absolute Function allows you to return the absolute positive number. In this math fabs program, We are going to find the absolute positive number of different values, and display the output.
/* FABS in C Programming Example */ #include <stdio.h> #include <math.h> int main() { printf("\n The Absolute Value of 0 = %.4f ", fabs(0)); printf("\n The Absolute Value of 1 = %.4f ", fabs(1)); printf("\n The Absolute Value of 152 = %.4f ", fabs(152)); printf("\n The Absolute Value of 400.36 = %.4f ", fabs(400.36)); printf("\n The Absolute Value of -27.32 = %.4f ", fabs(-27.32)); printf("\n The Absolute Value of -90 = %.4f ", fabs(-90)); return 0; }

C fabs Example 2
In this C Programming example, we are allowing the user to enter their own value. Next, this program uses the fabs function to find the absolute positive number of the user given value.
//* FABS in C Programming Example */ #include <stdio.h> #include <math.h> int main() { float number, absValue; printf(" Please Enter any Numeric Value : "); scanf("%f", &number); absValue = fabs(number); printf("\n The Absolute Value of %.2f = %.4f ", number, absValue); return 0; }
Please Enter any Numeric Value : -23.456
The Absolute Value of -23.46 = 23.4560