目录

double fmod(double x, double y)

描述 (Description)

C库函数double fmod(double x, double y)返回x的余数除以y

声明 (Declaration)

以下是fmod()函数的声明。

double fmod(double x, double y)

参数 (Parameters)

  • x - 这是具有除法分子iex的浮点值

  • y - 这是具有除法分母iey的浮点值

返回值 (Return Value)

此函数返回除x/y的余数。

例子 (Example)

以下示例显示了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
↑回到顶部↑
WIKI教程 @2018