You are here

ceil in C - math.h

Ceil function is used to round up a number i.e. it returns the smallest number which is greater than argument passed to it.

Declaration: double ceil(double);

C programming code

  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main()
  5. {
  6.   double n, result;
  7.  
  8.   printf("Enter a number to round it up\n");
  9.   scanf("%lf", &n);
  10.  
  11.   result = ceil(n);
  12.  
  13.   printf("Original number =  %.2lf\n", n);
  14.   printf("Number rounded up = %.2lf\n", result);
  15.  
  16.   return 0;
  17. }

Output of program:
ceil math.h C programming