C library function - fmod()


Advertisements

Description

The C library function double fmod(double x, double y) returns the remainder of x divided by y.

Declaration

Following is the declaration for fmod() function.

double fmod(double x, double y)

Parameters

  • x − This is the floating point value with the division numerator i.e. x.

  • y − This is the floating point value with the division denominator i.e. y.

Return Value

This function returns the remainder of dividing x/y.

Example

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

#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);
}

Let us compile and run the above program that will produce the following result −

Remainder of 9.200000 / 2 is 1.200000
Remainder of 9.200000 / 3.700000 is 1.800000
math_h.htm

Useful Video Courses


Video

JCL Online Training

12 Lectures 2 hours

Nishant Malik

Video

COBOL Online Training

12 Lectures 2.5 hours

Nishant Malik

Video

CRO Online Training

48 Lectures 6.5 hours

Asif Hussain

Video

Customer Service Online Training

12 Lectures 2 hours

Richa Maheshwari

Video

Cultivation of Crops

20 Lectures 3.5 hours

Vandana Annavaram

Video

Eclipse Online Training

44 Lectures 1 hours

Amit Diwan

Advertisements