cbrt()函数以及C ++中的示例
C++cbrt()函数
cbrt()函数是cmath标头的库函数,用于查找给定数字的立方根,它接受数字并返回立方根。
cbrt()函数语法:
cbrt(x);
参数:x–要计算其立方根的数字。
返回值:double-返回double值,它是给定数字x的立方根。
示例
Input:
int x = 2;
Function call:
cbrt(x);
Output:
1.25992C++代码演示cbrt()函数示例
//示例
//cbrt()功能
#include <iostream>
#include <cmath>
using namespace std;
//主代码部分
int main(){
float x;
//输入值
cout<<"Enter a number: ";
cin>>x;
//计算平方根
float result = cbrt(x);
cout<<"cubic root of "<<x<<" is = "<<result;
cout<<endl;
return 0;
}输出结果
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
热门推荐
10 新人红包祝福语简短精辟
11 幼师给毕业祝福语简短
12 生日高考祝福语妹妹简短
13 下飞机祝福语简短英文
14 元宵发客户祝福语简短
15 爸妈金婚文案祝福语简短
16 新郎朋友红包祝福语简短
17 虎年五一祝福语大全简短
18 出阁宴祝福语姐姐简短