Grokking Modern System Design Interview for Engineers & Managers
Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.
The fmod()
function is used to return the modulus value of a fraction of two floating-point numbers (x/y
) passed to the function as an argument.
In simple terms, the fmod()
function returns the floating-point remainder of $\frac{x}{y}$.
double fmod(double x, double y);
float fmod(float x, float y):
long double fmod(long double x, long double y);
The fmod()
function takes two arguments (x
and y
) as its parameter values, where x
and y
represent the numerator and denominator, respectively.
The fmod()
function returns the floating-point remainder or modulus of x
and y
. It returns a NaN
value i.e (Not a Number) when the denominator y
is given as zero.
#include <iostream>#include <cmath>using namespace std;int main(){long double x = 10.55, y = 2.65;// using the fmod() functionlong double result = fmod(x, y);cout << "fmod(10.55, 2.65) = " << result << endl;x = -14.88, y = 2.06;// using the fmod() functionresult = fmod(x, y);cout << "fmod(-14.88, 2.06) =" << result << endl;return 0;}
Line 8: We declare two doubles, x
and y
.
Line 10: We use the fmod()
function to determine the remainder of x
divided by y
.
Line 11: We print the output of the fmod()
function applied on x
and y
.
Line 13: We assign new values to x
and y
.
Line 15: We use the fmod()
function to determine the remainder of x
divided by y
.
Line 16: We print the output of the fmod()
function applied on x
and y
.
RELATED TAGS
CONTRIBUTOR
Grokking Modern System Design Interview for Engineers & Managers
Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.