C ceil() function
C ceil() function - Find integer
Syntax:
double ceil(double x)
The ceil() function is used to compute the smallest integer that is greater than or equal to x.
Parameters:
Name | Description | Required /Optional |
---|---|---|
x | Floating-point value. | Required |
Return value from ceil()
- Returns the integer as a double value.
Example: ceil() function
The following example shows the usage of ceil() function.
#include <math.h>
#include <stdio.h>
int main(void)
{
double x, y, z;
x = 123.345;
y = 1.05;
z = -1.05;
printf("Before applying ceil():");
printf("\nx = %.3f ; y = %.2f ; z = %.2f\n", x, y, z);
x = ceil(123.345);
y = ceil(1.05);
z = ceil(-1.05);
printf("\n\nAfter applying ceil():");
printf("\nx = %.3f ; y = %.2f ; z = %.2f\n", x, y, z);
}
Output:
Before applying ceil(): x = 123.345 ; y = 1.05 ; z = -1.05 After applying ceil(): x = 124.000 ; y = 2.00 ; z = -1.00
C Programming Code Editor:
Previous C Programming: C sqrt()
Next C Programming: C fabs()
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/c-programming/math/c-ceil.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics