In C++, the fabs() function is defined in the <cmath> or <math.h> header file and is used to calculate the absolute value of a given number. It removes the negative sign from a number and always returns a non-negative result.
The fabs() function supports float, double, and integer values.
Suppose a number is 'x':
It has the following syntax.
double fabs(double x); int fabs(int x);x: The value whose absolute value is to be determined.
It returns the absolute value of x.
Here, we are going to discuss several examples to demonstrate the List remainder() Function Function.
This example demonstrates how the fabs() function behaves when the input value is positive.
Output:
Value of x is :11.2 Absolute value of x is : 11.2
Explanation:
In this example, fabs() function determines the absolute value of x=11.2.
This example demonstrates how the fabs() function converts a negative value into a positive value.
Output:
Value of x is :-9.4 Absolute value of x is : 9.4
Explanation:
In this example, fabs() function computes the absolute value of x when the value of x is equal to -9.4.
This example demonstrates how the fabs() function behaves when the input value is zero.
Output:
Value of x is : 0 Absolute value of x is : 0
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India