Home >>C Math Functions >C math fmod() function
The C math fmod() function is used to return the remainder of x divided by y. It takes two different arguments x & y, one as a divisor and other as dividend and returns the value in type double. It is defined in <math.h> header file.
Syntax:double fmod(double x, double y)
Parameter | Description |
---|---|
x | It is the floating point value with the division numerator. |
y | It is the floating point value with the division denominator. |
#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);
}
#include <stdio.h>
#include <math.h>
int main ()
{
float a, b;
int c;
a = 63;
b = 3;
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);
}