#include#include int main() { double x = 3.14159; std::cout << "floor of " << x << " is " << std::floor(x) << std::endl; return 0; }
floor of 3.14159 is 3
#include#include int main() { double x = -4.5; std::cout << "floor of " << x << " is " << std::floor(x) << std::endl; return 0; }
floor of -4.5 is -5Description: In this example, the program takes a negative double value and finds its floor value using the std floor function. The result is -5 as the largest integer value less than or equal to -4.5 is -5. Package library: cmath (included in the standard library)