fmod : <math.h> library function

The function double fmod(double x, double y); returns the floating point remainder of x divided by y.

Function prototype of fmod

double fmod(double x, double y);
  • x : A floating point value of the numerator.
  • y : A floating point value of the denominator.

Return value of fmod

It returns remainder of dividing x by y.

C program to show the use of fmod function

The following program shows the use of fmod function to find the floating point remainder.

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

int main ()
{
  double num, denom, remainder;
  printf("Enter numerator and denominator\n");
  scanf("%lf %lf", &num, &denom);
  
  remainder = fmod(num, denom);
  printf("Remainder of %lf/%lf is %lf\n", num, denom, remainder);
  
  return 0;
}

Program Output
Enter numerator and denominator
12.5 3
Remainder of 12.500000/3.000000 is 0.500000