English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
C ++The ceil(x) function returns the smallest integer greater than or equal to x.
double ceil(double x); float ceil(float x); long double ceil(long double x); double ceil(T x); //is for integer
C ++The minimum possible integer value returned by ceil() function in<cmath>Defined in the header file.
The maximum value of the parameter used by ceil() function is calculated.
The minimum possible integer value returned by ceil() function is greater than or equal to the given parameter.
#include <iostream> #include <cmath> using namespace std; int main() { double x = 10.25, result; result = ceil(x); cout << "Ceil of " << x << " = " << result << endl; return 0; }
When the program is run, the output is:
Ceil of 10.25 = 11
#include <iostream> #include <cmath> using namespace std; int main() { int x = 15; double result; result = ceil(x); cout << "Ceil of " << x << " = " << result << endl; return 0; }
When the program is run, the output is:
Ceil of 15 = 15
For integer types, you will always get the same result, so this function is actually not used for integer types.