This blog is under construction

Monday, 30 April 2012

floor example in C

Header file:
    math.h

Synopsis:
     double floor(double x);

Description:
     Returns the floor of x.


floor function C example:


  #include<stdio.h>
  #include<math.h>
  int main() {
        double input, res;
        printf("Enter your input:");
        scanf("%lf", &input);
        res = floor(input);
        printf("floor(%lf):%lf\n", input, res);
        return 0;
  }



  Output:
  jp@jp-VirtualBox:~/cpgms/math$ gcc floor.c -lm
  jp@jp-VirtualBox:~/cpgms/math$ ./a.out
  Enter your input:8.9
  floor(8.900000):8.000000


No comments:

Post a Comment