该函数查找分子/分母的浮点余数(四舍五入到最接近的整数值),并且还将商内部存储到函数参数中传递的指针。
remquo - 语法
假设分子为“n”,分母为“d”,指针为“p”。语法为:
return_type remquo(data_type n, data_type d, int* p);
Note: return_type可以是float,double或long double。
remquo - 参数
n : 分子的值。
d : 分母的值。
p : 指向内部存储商的对象的指针。
remquo - 返回值
它返回浮点余数n/d。
remquo - 例子1
让我们看一个简单的例子,说明参数是相同类型的。
#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)<<
;
cout<<"Value of quotient is :"<<*p;
return 0;
}
输出:
Value of remainder is :2.2 Value of quotient is :1
remquo - 例子2
让我们看一个简单的示例,说明参数的类型不同。
#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)<<
;
cout<<"Value of quotient is :"<<*q;
return 0;
}
输出:
Value of remainder is :0.2 Value of quotient is :2