In C++, the ceil() function is defined in the <cmath> header file and is used to round a number upward to the nearest integer value that is not less than the given number. It always rounds toward positive infinity.
The ceil() function supports float, double, and long double values. It is commonly used in mathematics, graphics programming, scientific calculations, and applications where upward rounding is required.
For example
It has the following syntax.
x : It is the value that rounds to the nearest integer.
It returns the smallest integer value not less than x.
Here, we are going to discuss several examples to demonstrate the List ceil() Function Function.
This example demonstrates how the ceil() function rounds a positive floating-point number upward to the nearest integer.
Output:
Initial value of x is :9.2 final value of x is :10
This example demonstrates how the ceil() function behaves when the input value is negative.
Output:
Initial value of x is :-2.2 final value of x is :-2
This example demonstrates how the ceil() function behaves when the input value is already an integer. In this case, the same value is returned.
Output:
Initial value of x is : 15 Final value of x is : 15
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India