无涯教程-cbrt(x)函数

83 阅读1分钟

此函数用于查找给定数字的立方根。

Cube root of a number : arg

cbrt - 语法

double cbrt(double arg);
float cbrt(float arg);
long double cbrt(long double arg);
double cbrt(integral arg);

cbrt - 参数

arg : 它是float或整数类型的值。

cbrt - 返回值

它返回给定数字arg的立方根。

cbrt - 例子1

让我们看一个简单的示例,其中参数" arg"为整数类型

#include <iostream>  
#include<cmath>  
using namespace std;  
int main()  
{ 
  int arg=8;  
  std::cout << "Cube root of a number is :" <<cbrt(arg);  
  return 0;  
}  

输出:

Cube root of a number is :2

cbrt - 例子2

让我们看一个简单的示例,其中参数" arg"为浮点型。

#include <iostream>  
#include<cmath>  
using namespace std;  
int main()  
{  
 float arg=12.8;  
 std::cout << "Cube root of a number is :" <<cbrt(arg);  
  return 0;  
}  

输出:

Cube root of a number is :2.33921

参考链接

www.learnfk.com/c++/cpp-mat…