In the C Programming Language, the ceil feature returns the smallest integer that is higher than or equal to x (ie: rounds up the nearest integer).
Syntax
The syntax for the ceil feature in the C Language is:
double ceil(double x);
Parameters or Arguments
x
The value to round up to the nearest integer.
Returns
The ceil characteristic returns the smallest integer that is greater than or equal to x.
Required Header
In the C Language, the required header for the ceil function is:
#include <math.h>
Applies To
In the C Language, the ceil feature can be used in the following versions:
ANSI/ISO 9899-1990
ceil Example
/* Example using ceil by TechOnTheNet.com */
#include <stdio.h>
#include <math.h>
int main(int argc, const char * argv[])
{
/* Define temporary variables */
double value;
double result;
/* Assign the value we will find the ceil of */
value = 1.6;
/* Calculate the ceil of value */
result = ceil(value);
/* Display the result of the calculation */
printf("The ceil of %f is %f\n", value, result);
return 0;
}
When compiled and run, this utility will output:
The ceil of 1.600000 is 2.000000
Similar Functions
Other C functions that are comparable to the ceil function:
floor function <math.h>
Leave a Review