C语言 <math.h> fmod 函数 描述 C库函数double fmod(double x)返回x除以y的余数。 声明 以下是fmod函数的声明。 double fmod(double x, double y) 复制 参数 x - 浮点值,被除数。 y - 浮点值,除数。 返回值 此函数返回x / y除法的余数。 示例 以下示例显示fmod函数的用法- #include <stdio.h> #include <math.h> int main () { float a, b; int c; a = 9.2; b = 3.7; c = 2; printf("Remainder of %f / %d is %lf\n", a, c, fmod(a,c)); printf("Remainder of %f / %f is %lf\n", a, b, fmod(a,b)); return(0); } 复制尝试一下 让我们编译并运行上面的程序,它将产生以下结果- Remainder of 9.200000 / 2 is 1.200000 Remainder of 9.200000 / 3.700000 is 1.800000 复制 返回math.h头文件