For integral types, you will always get the same result, so this function is not used with integral types in practice.
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;
The ceil() function in C++ returns the smallest possible integer value which is greater than or equal to the given argument. This function is defined incmathheader file.
double ceil(double x); float ceil(float x); long double ceil(long double x); double ceil(T x); // For integral type
When you run the program, the output will be:
Example 1: ceil() function for double, float and long double types
ceil() prototype [As of C++ 11 standard]
The ceil() function in C++ returns the smallest possible integer value which is greater than or equal to the given argument.
You have successfully subscribed to our newsletter.
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;
You have successfully subscribed to our newsletter.
When you run the program, the output will be:
Example 2: ceil() function for integral types
The ceil() function returns the smallest possible integer value which is greater than or equal to the given argument.
Simplest programming tutorials for beginners
The ceil() function takes a single argument whose ceiling value is computed.
The ceil() function in C++ returns the smallest possible integer value which is greater than or equal to the given argument.