C Programming Tutorial
C Programming allows us to perform mathematical operations through the functions defined in
C Math Functions
In the C Programming Language, the ceil function returns the smallest integer that is greater than or equal to x (ie: rounds up the nearest integer).
Syntax
The syntax for the ceil function in the C Language is:
double ceil(double x);
Parameters or Arguments
The value to round up to the nearest integer.
Returns
The ceil function 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 function can be used in the following versions:
- ANSI/ISO 9899-1990
ceil Example
/* Example using ceil by c programming */ #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 application will output:
The ceil of 1.600000 is 2.000000