#include <math.h> double floor(double y);
floor
rounds a real number down to the next smaller integral real number.
floor
accepts a floating-point argument y
and rounds it down to
the next smaller integer expressed as a floating-point number.
floor
is implemented as a built-in function unless it is undefined by an
#undef
statement.
#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 less */ /* than the result. */ score = ( moda + modb); score /= df; rank = floor(score); /* Print the rounded result (its "floor"ed value). */ printf("The floor of (%d + %d)/ %d = %fn",moda,modb,df,rank); }
ceil
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.