cbrt函数_cbrt()函数以及C ++中的示例

cbrt函数

C ++ cbrt()函数 (C++ cbrt() function)

cbrt() function is a library function of cmath header, it is used to find the cubic root of a given number, it accepts a number and returns the cubic root.

cbrt()函数cmath标头的库函数,用于查找给定数字立方根 ,它接受数字并返回立方根。

Syntax of cbrt() function:

cbrt()函数的语法:

    cbrt(x);

Parameter(s): x – a number whose cubic root to be calculated.

参数: x-要计算其立方根的数字。

Return value: double – it returns double value that is the cubic root of the given number x.

返回值: double-它返回double值,它是给定数字x的立方根。

Example:

例:

    Input:
    int x = 2;

    Function call:
    cbrt(x);

    Output:
    1.25992

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

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

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

// main code section
int main()
{
    float x;
    
    //input the value
    cout<<"Enter a number: ";
    cin>>x;

    // calculate the square root
    float result = cbrt(x);
    cout<<"cubic root of "<<x<<" is = "<<result;
    cout<<endl;
    
    return 0;
}

Output

输出量

First run:
Enter a number: 10 
cubic root of 10 is = 2.15443 

Second run:
Enter a number: 123.45 
cubic root of 123.45 is = 4.97925 

Third run:
Enter a number: 0
cubic root of 0 is = 0

Fourth run:
Enter a number: -1234
cubic root of -1234 is = -10.726 


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

cbrt函数

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值