Function name : ceil
Header file : <math.h>
Function prototype : double ceil(double x);
Function : round up
Parameters : double x the double value to be operated on
Return value : Returns the smallest integer value >= x expressed in double precision.
Program example : Find the upward and downward rounding of number and output the result
#include<math.h>#include<stdio.h>intmain(void){doublenumber=123.54;doubledown,up;down=floor(number);up=ceil(number);printf(originalnumber%5.2lfn, number);printf(numberroundeddown%5.2lfn,down);printf(numberroundedup%5.2lfn,up);return0;}
Running results:
originalnumber123.54numberroundeddown123.00numberroundedup124.00