ceil value in c++ code example
Example 1: ceil value in c++ using formula
(a + b - 1) / b;
// this formula works for integer as well. ceil function in c++ takes double type value. To get ceil value for integer division you can simply use this expression without converting your datatype to double type.
Example 2: floor in c++
floor(x):This function in C++ returns the largest possible integer value which is smaller
than or equal to the given argument.
Input : 2.5 ,-2.1 ,2.9
Output : 2 ,-3, 2