ceil -- Round Up a Floating-Point Number


SYNOPSIS
#include <math.h>
double ceil(double y);
DESCRIPTION
ceil
rounds up a real number to the next larger integral real number.
RETURN VALUE
ceil
accepts a floating-point argument y
and rounds it up to the
next larger integer, expressed as a floating-point number.
IMPLEMENTATION
ceil
is implemented by a built-in function unless it is undefined by an
#undef
statement.
EXAMPLE
#include <math.h>
#include <stdio.h>
int moda, modb, df;
double score, rank;
main()
{
puts("Enter two integers: ");
scanf("%d %d", &moda, &modb);
puts("Enter an integer divisor: ");
scanf("%d",&df);
/* Add the two numbers, divide by the given divisor, and */
/* then round up to the closest integer greater than */
/* the result. */
score = (moda + modb);
score /= df;
rank = ceil(score);
/* Print this rounded result (its "ceil"ed value). */
printf("The ceiling of (%d + %d)/ %d = %fn",moda,modb,df,rank);
}
RELATED FUNCTIONS
floor
SEE ALSO
Mathematical Functions