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 program

#include <stdio.h>
#include <math.h>

int main()
{
  double n, result;

  printf("Enter a number to round it up\n");
  scanf("%lf", &n);

  result = ceil(n);

  printf("Original number =  %.2lf\n", n);
  printf("Number rounded up = %.2lf\n", result);

  return 0;
}

Output of program:
ceil math.h C programming