The std::cbrt() is an inbuilt function in C++ STL which is used to calculate the cube root of number. It accepts a number as argument and returns the cube root of that number.
// Returns cube root num (num can be // of type int, double, long double or // long long type. // The return type is same as parameter // passed. cbrt(num)
Parameter: The parameter can be of int, double, long double or long long type.
Return Value: It returns the cube root of the number num. The datatype of returned cube root is same as that of the parameter passed except when an integer is passed as parameter. If the parameter passed is integral then the cbrt() function will return a value of type double.
Input : 8 Output : 2 Input : 9 Output : 2.08008
Below program illustrate the cbrt() function:
// CPP program to demonstrate the cbrt()
// STL function
using namespace std;
// cbrt() function with integral
int num1 = 9;
cout << cbrt(num1) << endl;
// cbrt() function with floating-point
double num2 = 7.11;
cout << cbrt(num2) << endl;
long long num3 = 7;
cout << cbrt(num3);
- Dividing a Large file into Separate Modules in C/C++, Java and Python
- How to delete a range of values from the List using Iterator
- How to create a List with Constructor in C++ STL
- How to delete last element from a List in C++ STL
- Can C++ reference member be declared without being initialized with declaration?
- Finding Floor and Ceil of a Sorted Array using C++ STL
- Some useful C++ tricks for beginners in Competitive Programming
- Replace each node with its Surpasser Count in Linked List
- Comparison of Java with other programming languages
- Print multiples of Unit Digit of Given Number
- Similarities and Differences between Ruby and C++
- Is body of a Default Constructor blank in C++?
- clocale header file in C++
- Commonly used String functions in C/C++ with Examples
- Difference between C and C++
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.