Skip to content
Home » fabs() function to find absolute value in C

fabs() function to find absolute value in C

Learn about fabs() function to find absolute value in C in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

fabs() function to find absolute value in C

#include<stdio.h>
#include<stdlib.h>
int main()
{
  double number;
  double result;

  printf("Enter a number: ");
  scanf("%lf", &number);

  result = fabs(number);
  printf("Absolute value = %lf\n", result);

  return 0;
}

Output:

Enter a number: -10.7
Absolute value = 10.7

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Codes :
labs() function to find absolute value in C
Program to return Absolute value in C