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 
#include 
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 "<输出量 

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函数

你可能感兴趣的:(c++,python,java,javascript,js)