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

C ++ restder()函数 (C++ remainder() function)

remainder() function is a library function of cmath header, it is used to calculate the remainder (IEC 60559), it accepts two parameters (numerator and denominator) and returns the remainder (floating-point) of numerator/denominator rounded to nearest,

restder()函数cmath标头的库函数,用于计算余数(IEC 60559),它接受两个参数( 分子分母 ),并返回四舍五入到最接近的分子 / 分母的余数(浮点数),

    remainder = numerator - rquot * denominator

Where, rquot is the value of numerator/denominator (rounded to the nearest integral value with halfway cases rounded toward the even number.

其中, rquot分子 / 分母的值(四舍五入为最接近的整数值,中位数为四舍五入为偶数)。

Syntax of remainder() function:

restder()函数的语法:

C++11:

C ++ 11:

     double remainder (double numer     , double denom);
float remainder (float numer      , float denom);
long double remainder (long double numer, long double denom);
double remainder (Type1 numer      , Type2 denom);

Parameter(s):

参数:

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

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

Return value:

返回值:

It returns the remainder.

它返回余数。

Note:

注意:

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

    如果余数为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 = 15.46;
double y = 12.56;
Function call:
remainder(x, y);
Output:
2.9

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

// C++ code to demonstrate the example of
// remainder() function
#include <iostream>
#include <cmath>
using namespace std;
// main() section
int main()
{
double x;
double y;
x = 10;
y = 2;
cout << "remainder(" << x << "," << y << "): " << remainder(x, y);
cout << endl;
x = 5.3;
y = 2;
cout << "remainder(" << x << "," << y << "): " << remainder(x, y);
cout << endl;
x = 15.46;
y = 12.56;
cout << "remainder(" << x << "," << y << "): " << remainder(x, y);
cout << endl;
x = -10.2;
y = 2;
cout << "remainder(" << x << "," << y << "): " << remainder(x, y);
cout << endl;
return 0;
}

Output

输出量

remainder(10,2): 0
remainder(5.3,2): -0.7
remainder(15.46,12.56): 2.9
remainder(-10.2,2): -0.2

Reference: C++ remainder() function

参考: C ++ restder()函数

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

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

c语言 函数的参数传递示例_restder()函数,带有C ++中的示例相关推荐

  1. 函数指针(函数作为参数传递给其他函数)

    函数也有地址,函数的地址是存储其机器码的内存的开始的地址,并且函数的地址就是其函数名.因此我们可以将函数作为参数传递给其他函数.正如python中可以将函数轻易的传递给其他函数一样,但是C++中形式上 ...

  2. 【Groovy】Groovy 方法调用 ( Groovy 构造函数中为成员赋值 | Groovy 函数的参数传递与键值对参数 | 完整代码示例 )

    文章目录 一.Groovy 构造函数中为成员赋值 二.Groovy 函数的参数传递与键值对参数 三.完整代码示例 一.Groovy 构造函数中为成员赋值 Groovy 类没有定义构造函数 , 但是可以 ...

  3. 20 Python函数、定义一个函数、参数传递、匿名函数、return语句、变量作用域、

    20Python函数 函数是组织好的,可重复使用的,用来实现单一,或相关联功能的代码段. 函数能提高应用的模块性,和代码的重复利用率.你已经知道Python提供了许多内建函数,比如print().但你 ...

  4. C++中函数作为参数传递给其他函数

    简单的说,如果有函数的参数声明为函数指针类型的.则可以给函数传入另一个函数作为它的参数,在函数的内部可以调用传入的函数: 例如下面给一些例子: int add(int x, int y) // 定义函 ...

  5. python函数关键字参数传递_Python给函数传递不定关键字的参数

    转载请注明来自公众号『数据挖掘机养成记』 前言 在上一篇文章『[Python]给函数传递不定个数的参数』中,我们主要讲解了*在函数定义和函数调用阶段的不同作用,并留了一个小问题: 我们用*定义了add ...

  6. scala语言示例_var关键字与Scala中的示例

    scala语言示例 Scala var关键字 (Scala var keyword) The var Keyword in scala is used to declare variables. As ...

  7. R语言笔记7:functions——编写函数所需的基础知识

    上一讲通过三个简单的例子体验了一下如何在R中写函数,下面来详细学习有关R语言中函数的知识. Functions in R 主要分三个部分来讲解函数: 编写函数所需的基础知识 相关语法作用域 R语言作用 ...

  8. python函数定义及调用-python函数的定义和调用 | 酷python

    python函数的定义与调用 在python中 ,函数是一个组织好的 ,可以重复使用的代码段 ,函数可以提高代码的重复利用率 ,原则上一个函数只实现一个单一的功能 ,这样能增强程序的模块性, pyth ...

  9. 阻塞式回调函数和延迟式回调函数

    首先,有三种函数: 起始函数:大致可以等同于主函数 中间函数:中间函数把回调函数作为参数传递执行 回调函数:一个有独立功能的函数 怎么理解: 你到一个商店买东西,刚好你要的东西没有货,于是你在店员那里 ...

最新文章

  1. html5学习笔记1
  2. uwsgi基础——最佳实践和问题
  3. 用友t3服务器文件丢失,用友T3软件在T3用友通标准版恢复账套时在备份的文件中找不到要恢复的文件,如何解决?-用友T3...
  4. thinkphp跨库操作代码实例
  5. Oracle 20c 新特性知多少?ANSI SQL 全支持之 EXCEPT 运算符增强
  6. YFI 创始人 Andre Cronje:有四个新产品待发布,但担心在推出后被分叉
  7. DataGridView默认不选中
  8. 《Effective Python 2nd》——推导与生成
  9. 1. 初识ZooKeeper。
  10. python numpy安装教程_python 环境下安装 numpy
  11. JAVA知识点(尚硅谷宋红康老师的b站授课自我整理)
  12. Win10 安装rational rose 7教程
  13. 如何快速翻译医学类英文专业文献?
  14. 使用redis实现附近的人
  15. res.send和res.sendFile
  16. 如果计算机电源突然断电 会导致,电脑突然断电问题
  17. 【Latex】Texstudio英文拼写错误检查功能出问题的解决方法
  18. 盘点三种卫星图分幅导出的方法
  19. Linux和Windows误删文件恢复办法
  20. 【厚积薄发系列】读书笔记4—《伙伴教练:转化团队高效能的关键力量》小记

热门文章

  1. 韦冬雪计算机应用,捕获效应下RFID防碰撞算法的研究与应用
  2. ios 查询mysql数据库操作系统_iOS数据库FMDB--增删改查(模糊查询)详细介绍
  3. django中间件及中间件实现的登录验证
  4. 贝塞尔曲线理解与应用
  5. 简单却实用的的例子:Jquery获取 radio 选中后的文字
  6. Html5中新增的表单元素详解
  7. Day1 了解web前端
  8. 《软件工程导论》课后习题解答
  9. AFN\HTTPS\UIWebView
  10. python基础(一)简单入门