This function is used to return the remainder(modulus) of 2 floating point numbers mentioned in its arguments and also stores the quotient to the pointer passed to it. The quotient computed is rounded.
remainder = number – rquot * denom
Where rquot is the result of: numerator/denominator, rounded toward the nearest integral value (with halfway cases rounded toward the even number).
long double remquo(long double a, long double b, int* q); double remquo(double a, double b, int* q); float remquo(float a, float b, int* q);
- a and b are the values of numerator and denominator. q is the pointer in which quotient will be stored.
- It returns the floating point remainder of numerator/denominator rounded to nearest and stores quotient in q.
- It is mandatory to give all the three arguments otherwise it will give error no matching function for call to ‘remquo’.
- It is mandatory to pass third argument a pointer because it stores address of quotient otherwise it will give error ‘remquo(double&, double&, int&)’
Input : remquo(12.5, 2.2, &q) Output : -0.7 and q=6
Input : remquo(-12.5, 2.2, &q) Output : 0.7 and q=-6
# CODE 1
Remainder of 12.5/2.2 is -0.7 Quotient of 12.5/2.2 is 6 Remainder of -12.5/2.2 is 0.7 Quotient of -12.5/2.2 is -6 Remainder of -12.5/0 is -nan Quotient of -12.5/0 is -6
# CODE 2
Remainder of 12.5/2 is 0.5 Quotient of 12.5/2 is 6
- C++ Floating Point Manipulation (fmod(), remainder(), remquo() ... in cmath)
- C/C++ if else statement with Examples
- C/C++ if statement with Examples
- C/C++ do while loop with Examples
- C/C++ while loop with Examples
- C/C++ if else if ladder with Examples
- C++ boost::dynamic_bitset Class with Examples
- Synchronous Chatting Application using C++ boost::asio
- C/C++ For loop with Examples
- How to input a comma separated string in C++?
- Program to Parse a comma separated string in C++
- Difference between Private and Protected in C++ with Example
- Difference between Inheritance and Polymorphism
- Difference between Single and Multiple Inheritance in C++
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.