floor() returns the largest integral value that is not greater than its argument. The return type is double.
double floor(double x);#include <math.h>
#include <stdio.h>
int main(void) {
double value = 5.8;
printf("floor(5.8): %.1f\\n", floor(value));
return 0;
}#include <math.h>
#include <stdio.h>
int main(void) {
double value = -5.2;
printf("floor(-5.2): %.1f\\n", floor(value));
return 0;
}
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.