We will learn about fabs Arithmetic function in C programming Language
In the C Programming Language, the fabs() arithmetic function returns the absolute value of a floating point.
Syntax
The syntax of the fabs() function in the C programming Language
double fabs(double x);
x is the parameter or argument of this function to convert to an absolute value;
When a value is passed for x, this function returns the absolute value of x
In the C Language, the required header file for fabs() function is
#include <math.h>
The following example explains the usage of fabc() function
Program 1
#include <stdio.h> #include <stdlib.h> #include <math.h> int main() { double a=345.93,b=-57.34;//assign variables printf("the absolute value of a: %f\n",fabs(a)); printf("te absolute value of b: %f\n",fabs(b)); //display fabs values of given value return 0; }
When the above program is compiled and run, it will produce the following result
the absolute value of a:345.930000
the absolute value of a:57.340000
Program 2
#include <stdio.h> #include <math.h> int main() { double value1, value2,result1,result2;//declare local variable printf("Enter the positive float value :"); scanf("%lf",&value1);//get input for value1 printf("Enter the Negative float value :"); scanf("%lf",&value2);//get input for value1 result1=fabs(value1);//find and assign absolute value to result1 result2=fabs(value2);//find and assign absolute value to result1 printf("fabs value of %lf is : %.2lf\n",value1,result1); printf("fabs value of %lf is : %.2lf\n",value2,result2); //display result of given values getch(); return 0; }
When the above program is compiled and run , it will produce the following result
Enter the positive float value: 45.65 Enter the positive float value: -34.67 fabs value of 45.650000 is : 45.65 fabs value of 34.670000 is : 34.67
Similar Functions
Other C programming language functions that are similar to the cosine function
suggested for you
User defined function in C language
Arithmetic functions in C Language
C# inverted full pyramid star pattern In this article, we will discuss the concept of…
C# Full Pyramid star pattern program In this article, we will discuss the concept of…
Program to count vowels, consonants, words, characters and space in Java In this article, we…
How to print multiplication table using Array in C++ language In this post, we will…
C Program to multiplication table using Array In this tutorial , we will discuss about…
Java program to check odd or even using recursion In this tutorial, we discuss a…