This blog is under construction

Monday, 30 April 2012

fabs example in C

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;
  }



  Output:
  jp@jp-VirtualBox:~/cpgms/math$ ./a.out
  Enter your input:-123
  Absolute value of -123.000000 is 123.000000



No comments:

Post a Comment