Chapter Contents |
Previous |
Next |
ceil |
Portability: | ISO/ANSI C conforming, UNIX compatible |
SYNOPSIS | |
DESCRIPTION | |
RETURN VALUE | |
IMPLEMENTATION | |
EXAMPLE | |
RELATED FUNCTIONS | |
SEE ALSO |
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 = %f\n",moda,modb,df,rank); }
RELATED FUNCTIONS |
SEE ALSO |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.