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函数
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/bian-cheng-ji-chu/108273.html