fmod() – C函数
C库函数double fmod(double x, double y)返回x除以y的剩余的值。
声明
以下是fmod() 函数的声明。
double fmod(double x,double y)
参数
-
x -- 这是除法分子IEX浮点值 i.e. x.
-
y -- 这是浮动点值除法分母iey
返回值
这个函数返回除以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 ", a, c, fmod(a,c)); printf("Remainder of %f / %f is %lf ", a, b, fmod(a,b));return(0);}
让我们编译和运行上面的程序,这将产生以下结果:
Remainder of 9.200000 / 2 is 1.200000 Remainder of 9.200000 / 3.700000 is 1.800000