C++ Math remquo
The function calculates the floating-point modulus of the numerator divided by the denominator (rounded to the nearest integer) and simultaneously saves the quotient internally to the pointer provided as a parameter to the function.
Syntax
Suppose 'n' represents the numerator, 'd' represents the denominator, and 'p' represents the pointer. The syntax for this scenario would be as follows:
return_type remquo(data_type n, data_type d, int* p);
Note: The return_type can be float, double or long double.
Parameter
n : The value of numerator.
d : The value of denominator.
The pointer refers to an object where the result of the division operation is internally stored.
Return value
It returns the floating point remainder n/d.
Example 1
Let's explore a basic scenario where the parameters are of identical data type.
#include <iostream>
#include<math.h>
using namespace std;
int main()
{
float x=7.6;
float y=5.4;
int* p;
std::cout << "Value of remainder is :" << remquo(x,y,p)<<'\n';
cout<<"Value of quotient is :"<<*p;
return 0;
}
Output:
Value of remainder is :2.2
Value of quotient is :1
Example 2
Let's explore a basic scenario where the parameters are of varying data types.
#include <iostream>
#include<math.h>
using namespace std;
int main()
{
int x=2;
float y=1.1;
int* q;
std::cout << "Value of remainder is :" <<remquo(x,y,q)<<'\n';
cout<<"Value of quotient is :"<<*q;
return 0;
}
Output:
Value of remainder is :0.2
Value of quotient is :2