Header file:
math.h
Synopsis:
double fabs(double x);
Description:
Returns the absolute value of x.
fabs function C example:
#include<stdio.h>
#include<math.h>
int main() {
double x, res;
printf("Enter your input:");
scanf("%lf", &x);
res = fabs(x);
printf("Absolute value of %lf is %lf\n", x, res);
return 0;
}
#include<math.h>
int main() {
double x, res;
printf("Enter your input:");
scanf("%lf", &x);
res = fabs(x);
printf("Absolute value of %lf is %lf\n", x, res);
return 0;
}
Output:
jp@jp-VirtualBox:~/cpgms/math$ ./a.out
Enter your input:-123
Absolute value of -123.000000 is 123.000000
Enter your input:-123
Absolute value of -123.000000 is 123.000000
This comment has been removed by the author.
ReplyDelete