#include <math.h>
double fmod( double x, double y );
函数返回参数 x/y 的余数。
#include <stdio.h> #include <math.h> int main(void) { double x = 5.0, y = 2.0; double result; result = fmod(x,y); printf("The remainder of (%lf / %lf) is \ %lf\n", x, y, result); return 0; }
输出结果:
The remainder of (5.000000 / 2.000000) is 1.000000