c语言fmod函数_fmod()函数以及C ++中的示例

news/2024/7/10 0:47:10 标签: javascript, js, php, python, vue

c语言fmod函数

C ++ floor()函数 (C++ floor() function)

fmod() function is a library function of cmath header, it is used to find the remainder of the division, it accepts two numbers (numerator and denominator) and returns the floating-point remainder of numerator/denominator which is rounded towards to zero.

fmod()函数cmath标头的库函数,用于查找除法的余数,它接受两个数字(分子和分母),并返回四舍五入为零的分子/分母的浮点余数。

Syntax of fmod() function:

fmod()函数的语法:

    fmod(n, m);

Parameter(s): n,m – are the numbers (numerator, denominator) to be used to calculate the remainder of the division.

参数: n,m –是用于计算除法余数的数字(分子,分母)。

Return value: double – it returns double type value that is floating-point remainder of the division.

返回值: double-返回double类型的值,该值是除法的浮点余数。

Example:

例:

    Input:
    float n = 5.3;
    float m = 2;
    
    Function call:
    fmod(n,m);
    
    Output:
    1.3

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

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

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

// main() section
int main()
{
    float n;
    float m;
    float result;
    
    //input the value of 
    //numerator and denominator
    cout<<"Enter the value of numerator  : ";
    cin>>n;
    cout<<"Enter the value of denominator: ";
    cin>>m;
    
    //finding the remainder
    result = fmod(n,m);
    cout<<"floating-point remainder of "<<n<<"/"<<m<<" is: ";
    cout<<result<<endl;

    return 0;
}

Output

输出量

Enter the value of numerator: 5.3
Enter the value of denominator: 2
floating-point remainder of 5.3/2 is: 1.3

Second run:
Enter the value of numerator: 18.5 
Enter the value of denominator: 4.2
floating-point remainder of 18.5/4.2 is: 1.7

Third run:
Enter the value of numerator: -36.23 
Enter the value of denominator: 24.1 
floating-point remainder of -36.23/24.1 is: -12.13 

Fourth run:
Enter the value of numerator: 36.23
Enter the value of denominator: -24.1
floating-point remainder of 36.23/-24.1 is: 12.13


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

c语言fmod函数


http://www.niftyadmin.cn/n/1256498.html

相关文章

c语言中sqrt函数_sqrt()函数以及C ++中的示例

c语言中sqrt函数C sqrt()函数 (C sqrt() function) sqrt() function is a library function of cmath header (<math.h> in earlier versions), it is used to find the square root of a given number, it accepts a number and returns the square root. sqrt()函数是…

spring-mvc注解配置小记

Controller中注解Service时&#xff0c;Service的实现类需加Service&#xff0c;dao的实现类需加Repository。 另&#xff1a;配置文件中对应的包也需要扫描到&#xff01;&#xff01;&#xff01; <context:annotation-config /><!-- 启动注解 --> <!--上下文…

sinh函数_sinh()函数以及C ++中的示例

sinh函数C sinh()函数 (C sinh() function) sinh() function is a library function of cmath header, it is used to find the hyperbolic sine of the given value (hyperbolic angle), it accepts a number (x) and returns the hyperbolic sine of x. 双曲正弦()函数是CMA…

python 示例_Python中带有示例的finally关键字

python 示例Python最终关键字 (Python finally keyword) finally is a keyword (case-sensitive) in python, it is a part of "try...except...finally" block, it is used to define a block (of coding statements) to execute finally i.e. no matter there is a…

c++中tan函数_tan()函数以及C ++中的示例

c中tan函数C tan()函数 (C tan() function) tan() function is a library function of cmath header, it is used to find the tangent of the given number (angle), it accepts a number (x) and returns the tangent of angle x radians. tan()函数是cmath标头的库函数&…

vc++ cos 函数_cos()函数以及C ++中的示例

vc cos 函数C cos()函数 (C cos() function) cos() function is a library function of cmath header, it is used to find the cosine of the given number (angle), it accepts a number (x) and returns the cosine of angle x radians. cos()函数是cmath标头的库函数&…

python中int函数_int()函数以及Python中的示例

python中int函数Python int()函数 (Python int() function) int() function is used to convert a string (that should contain a number/integer), number (integer, float) into an integer value. int()函数用于将字符串(应包含数字/整数)&#xff0c;数字(整数&#xff0c…

PhpStorm的破解 汉化

以前一直习惯使用sublime&#xff0c;最近发现phpstorm比submit稍微更强大些&#xff0c;其很多插件都是直接可以使用&#xff0c;不需要另外去拓展了 其中的破解、汉化步骤就需要借助一些资源 &#xff08;1&#xff09;破解 安装完毕后&#xff0c;直接打开即进入注册步骤 直…