#include <stdio.h>
int main() {
printf("\nNumber = %.2f", ceil(14.32)); // Number = 15.00
printf("\nNumber = %.2f", ceil(14.52)); // Number = 15.00
printf("\nNumber = %.2f", ceil(14.82)); // Number = 15.00
printf("\nNumber = %.2f", ceil(-14.32));// Number = -14.00
printf("\nNumber = %.2f", ceil(-14.82));// Number = -14.00
return 0;
}
We will get lowest integer higher than the input data by using ceil() function. Output is the nearest integer ( on higher side ) of the number.
#include <stdio.h>
#include <math.h>
int main(void){
float num; // num is declared as float variable
num=17.873; // data is stored
printf("num = %.4f", ceil(num)); // final output
return 0;
}
The above code will give this output.
num = 18.0000
Example with negative value
#include
#include
int main(void){
float num; // num is declared as float variable
num=-17.873; // data is stored
printf("num = %.4f", ceil(num)); // final output
return 0;
}