c语言 函数的参数传递示例_restder()函数,带有C ++中的示例
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 ++中的示例相关推荐
- 函数指针(函数作为参数传递给其他函数)
函数也有地址,函数的地址是存储其机器码的内存的开始的地址,并且函数的地址就是其函数名.因此我们可以将函数作为参数传递给其他函数.正如python中可以将函数轻易的传递给其他函数一样,但是C++中形式上 ...
- 【Groovy】Groovy 方法调用 ( Groovy 构造函数中为成员赋值 | Groovy 函数的参数传递与键值对参数 | 完整代码示例 )
文章目录 一.Groovy 构造函数中为成员赋值 二.Groovy 函数的参数传递与键值对参数 三.完整代码示例 一.Groovy 构造函数中为成员赋值 Groovy 类没有定义构造函数 , 但是可以 ...
- 20 Python函数、定义一个函数、参数传递、匿名函数、return语句、变量作用域、
20Python函数 函数是组织好的,可重复使用的,用来实现单一,或相关联功能的代码段. 函数能提高应用的模块性,和代码的重复利用率.你已经知道Python提供了许多内建函数,比如print().但你 ...
- C++中函数作为参数传递给其他函数
简单的说,如果有函数的参数声明为函数指针类型的.则可以给函数传入另一个函数作为它的参数,在函数的内部可以调用传入的函数: 例如下面给一些例子: int add(int x, int y) // 定义函 ...
- python函数关键字参数传递_Python给函数传递不定关键字的参数
转载请注明来自公众号『数据挖掘机养成记』 前言 在上一篇文章『[Python]给函数传递不定个数的参数』中,我们主要讲解了*在函数定义和函数调用阶段的不同作用,并留了一个小问题: 我们用*定义了add ...
- scala语言示例_var关键字与Scala中的示例
scala语言示例 Scala var关键字 (Scala var keyword) The var Keyword in scala is used to declare variables. As ...
- R语言笔记7:functions——编写函数所需的基础知识
上一讲通过三个简单的例子体验了一下如何在R中写函数,下面来详细学习有关R语言中函数的知识. Functions in R 主要分三个部分来讲解函数: 编写函数所需的基础知识 相关语法作用域 R语言作用 ...
- python函数定义及调用-python函数的定义和调用 | 酷python
python函数的定义与调用 在python中 ,函数是一个组织好的 ,可以重复使用的代码段 ,函数可以提高代码的重复利用率 ,原则上一个函数只实现一个单一的功能 ,这样能增强程序的模块性, pyth ...
- 阻塞式回调函数和延迟式回调函数
首先,有三种函数: 起始函数:大致可以等同于主函数 中间函数:中间函数把回调函数作为参数传递执行 回调函数:一个有独立功能的函数 怎么理解: 你到一个商店买东西,刚好你要的东西没有货,于是你在店员那里 ...
最新文章
- html5学习笔记1
- uwsgi基础——最佳实践和问题
- 用友t3服务器文件丢失,用友T3软件在T3用友通标准版恢复账套时在备份的文件中找不到要恢复的文件,如何解决?-用友T3...
- thinkphp跨库操作代码实例
- Oracle 20c 新特性知多少?ANSI SQL 全支持之 EXCEPT 运算符增强
- YFI 创始人 Andre Cronje:有四个新产品待发布,但担心在推出后被分叉
- DataGridView默认不选中
- 《Effective Python 2nd》——推导与生成
- 1. 初识ZooKeeper。
- python numpy安装教程_python 环境下安装 numpy
- JAVA知识点(尚硅谷宋红康老师的b站授课自我整理)
- Win10 安装rational rose 7教程
- 如何快速翻译医学类英文专业文献?
- 使用redis实现附近的人
- res.send和res.sendFile
- 如果计算机电源突然断电 会导致,电脑突然断电问题
- 【Latex】Texstudio英文拼写错误检查功能出问题的解决方法
- 盘点三种卫星图分幅导出的方法
- Linux和Windows误删文件恢复办法
- 【厚积薄发系列】读书笔记4—《伙伴教练:转化团队高效能的关键力量》小记