Latest web development tutorials

C library functions - fmod ()

C standard library - <math.h> C standard library - <math.h>

description

C library functionsdouble fmod (double x, double y ) Returns the remainder of xdivided byy.

statement

Here is the fmod () function's declaration.

double fmod(double x, double y)

parameter

  • x - the floating-point value represents the molecule.
  • y - on behalf of the denominator of floating-point values.

return value

This function returns the x / y of the remainder.

Examples

The following example demonstrates fmod () function is used.

#include <stdio.h>
#include <math.h>

int main ()
{
   float a, b;
   int c;
   a = 9.2;
   b = 3.7;
   c = 2;
   printf("%f / %d 的余数是 %lf\n", a, c, fmod(a,c));
   printf("%f / %f 的余数是 %lf\n", a, b, fmod(a,b));
   
   return(0);
}

Let's compile and run the above program, which will result in the following:

9.200000 / 2 的余数是 1.200000
9.200000 / 3.700000 的余数是 1.800000

C standard library - <math.h> C standard library - <math.h>