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++ | asm declaration
- Pointers and References in C++
- Strings in C++ and How to Create them?
- Enum Classes in C++ and Their Advantage over Enum DataType
- Deque vs Vector in C++ STL
- C++ Programming Basics
- Introduction to C++ Programming Language
- ios manipulators noshowpos() function in C++
- ios rdstate() function in C++ with Examples
- ios operator !() function in C++ with Examples
- ios operator() function in C++ with Examples
- ios clear() function in C++ with Examples
- ios good() function in C++ with Examples
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.