c语言 函数的参数传递示例_remquo()函数与C ++中的示例

c语言 函数的参数传递示例

C ++ remquo()函数 (C++ remquo() function)

remquo() function is a library function of cmath header. It is used to calculate the remainder and quotient, this function is the same as the remainder() function, but this function also stores the quotient that can be used further. It accepts three parameters (numerator, denominator, and quotient) and returns the remainder, assigns the quotient in the third parameter which should be a pointer.

remquo()函数cmath标头的库函数。 它用于计算余数和商,此函数与restder()函数相同 ,但是此函数还存储可以进一步使用的商。 它接受三个参数( numeratordenominatorquotient )并返回余数,在第三个参数中分配商,它应该是一个指针。

Syntax of remquo() function:

remquo()函数的语法:

C++11:

C ++ 11:

     double remquo (double numer     , double denom     , int* quot);
      float remquo (float numer      , float denom      , int* quot);
long double remquo (long double numer, long double denom, int* quot);
     double remquo (Type1 numer      , Type2 denom      , int* quot);

Parameter(s):

参数:

  • numer, denom – represent the values of numerator and denominator.

    numer,denom –表示分子分母的值。

  • *quot– represents an integer pointer to store the quotient.

    * quot –表示存储商的整数指针。

Return value:

返回值:

It returns the remquo.

它返回remquo。

Note:

注意:

  • If the remquo is 0, then its sign is the same as the sign of numer.

    如果remquo为0,则其符号是相同的NUMER的符号。

  • If the value of denom is 0, the result may either 0 or it may cause a domain error.

    如果denom的值为0,则结果可能为0或可能导致域错误。

Example:

例:

    Input:
    double x = 10.34;
    double y = 2.5;
    double rem;
    int quo;
    
    Function call:
    remquo(x, y, &quo);
    
    Output:
    rem = 0.34
    quo = 4

C ++代码演示remquo()函数的示例 (C++ code to demonstrate the example of remquo() function)

// C++ code to demonstrate the example of
// remquo() function

#include <iostream>
#include <cmath>
using namespace std;

// main() section
int main()
{
    double x;
    double y;
    double r;
    int q;

    x = 10;
    y = 2;

    r = remquo(x, y, &q);
    cout << "numerator  : " << x << endl;
    cout << "denominator: " << y << endl;
    cout << "remainder  : " << r << endl;
    cout << "quotient   : " << q << endl;
    cout << endl;

    x = 10.34;
    y = 2.5;

    r = remquo(x, y, &q);
    cout << "numerator  : " << x << endl;
    cout << "denominator: " << y << endl;
    cout << "remainder  : " << r << endl;
    cout << "quotient   : " << q << endl;
    cout << endl;

    x = -10.02;
    y = 2.3;

    r = remquo(x, y, &q);
    cout << "numerator  : " << x << endl;
    cout << "denominator: " << y << endl;
    cout << "remainder  : " << r << endl;
    cout << "quotient   : " << q << endl;
    cout << endl;

    x = 10.23;
    y = -2.0;

    r = remquo(x, y, &q);
    cout << "numerator  : " << x << endl;
    cout << "denominator: " << y << endl;
    cout << "remainder  : " << r << endl;
    cout << "quotient   : " << q << endl;
    cout << endl;

    return 0;
}

Output

输出量

numerator  : 10
denominator: 2
remainder  : 0
quotient   : 5

numerator  : 10.34
denominator: 2.5
remainder  : 0.34
quotient   : 4

numerator  : -10.02
denominator: 2.3
remainder  : -0.82
quotient   : -4

numerator  : 10.23
denominator: -2
remainder  : 0.23
quotient   : -5

Reference: C++ remquo() function

参考: C ++ remquo()函数

翻译自: https://www.includehelp.com/cpp-tutorial/remquo-function-with-example.aspx

c语言 函数的参数传递示例

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值