totn C Functions

C Language: fmod function
(Floating Modulus)

In the C Programming Language, the fmod function returns the remainder when x is divided by y.

Syntax

The syntax for the fmod function in the C Language is:

double fmod(double x, double y);

x is divided by y.

Returns

The fmod function returns the remainder when x is divided by y.

Required Header

In the C Language, the required header for the fmod function is:

#include <math.h>

Applies To

In the C Language, the fmod function can be used in the following versions:

  • ANSI/ISO 9899-1990

fmod Example

/* Example using fmod by TechOnTheNet.com */

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

int main(int argc, const char * argv[])
{
    /* Define temporary variables */
    double value1, value2;
    double result;

    /* Assign the values we will find the fmod of */
    value1 = 1.6;
    value2 = 1.2;

    /* Calculate the remainder of value1 / value2 */
    result = fmod(value1, value2);

    /* Display the result of the calculation */
    printf("The fmod of %f and %f is %f\n", value1, value2, result);

    return 0;
}

When compiled and run, this application will output:

The fmod of 1.600000 and 1.200000 is 0.400000

Similar Functions

Other C functions that are similar to the fmod function: