C Programming Tutorial
C Programming allows us to perform mathematical operations through the functions defined in
C Math Functions
In the C Programming Language, the floor function returns the largest integer that is smaller than or equal to x (ie: rounds downs the nearest integer).
Syntax
The syntax for the floor function in the C Language is
double floor(double x);
Parameters or Arguments
The value to round down to the nearest integer.
Returns
The floor function returns the largest integer that is smaller than or equal to x.
Required Header
In the C Language, the required header for the floor function is:
#include <math.h>
Applies To
In the C Language, the floor function can be used in the following versions
- ANSI/ISO 9899-1990
floor Example
/* Example using floor by c programming */ #include <stdio.h> #include <math.h> int main(int argc, const char * argv[]) { /* Define temporary variables */ double value; double result; /* Assign the value we will find the floor of */ value = 1.6; /* Calculate the floor of value */ result = floor(value); /* Display the result of the calculation */ printf("The floor of %f is %f\n", value, result); return 0; }
When compiled and run, this application will output
The floor of 1.600000 is 1.000000