#include#include int main() { double x = 3.14159; std::cout << "Ceiling of " << x << " is " << std::ceil(x) << std::endl; return 0; }
Ceiling of 3.14159 is 4
#include#include int main() { double x = -2.71828; std::cout << "Ceiling of " << x << " is " << std::ceil(x) << std::endl; return 0; }
Ceiling of -2.71828 is -2In both of these examples, we include the cmath library and call the std::ceil function to round the number up to the nearest integer. The std::ceil function is part of the C++ standard library, which means it is included in the standard C++ library package.