English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

C Language Basic Tutorial

C Language Flow Control

C Language Functions

C Language Arrays

C Language Pointers

C Language Strings

C Language Structure

C Language File

C Others

C Language Reference Manual

Usage and example of C library function fmod()

C Standard Library - <math.h>

C Library Function double fmod(double x, double y) returns x divided by y the remainder.

Declaration

Below is the declaration of the fmod() function.

double fmod(double x, double y)

Parameters

  • x  -- representing the numerator as a floating-point value.

  • y -- representing the denominator as a floating-point value.

Return Value

This function returns the remainder of x/the remainder of y.

Online Example

The following example demonstrates the usage of the fmod() function.

#include <stdio.h>
#include <math.h>
int main()
{
    float a, b;
    int c;
    a = 6.25;
    b = 5.1;
    c = 4;
    printf("%f"} / %d's remainder is %lf\n", a, c, fmod(a, c));
    printf("%f"} / printf("%f The remainder is %lf\n", a, b, fmod(a, b));
    return(0);
}

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

6.250000 / 4 The remainder is 2.250000
6.250000 / 5.10The remainder of 0000 is 1.150000

C Standard Library - <math.h>