C++ cbrt()
Published Jul 20, 2021Updated Jul 31, 2023
Contribute to Docs
The cbrt() function returns the cube root of the argument.
Syntax
std::cbrt(n)
Example
Use cbrt() to find the side lengths of a 27 m3 cube:
#include <iostream>#include <cmath>int main() {double V = 27;double side;side = std::cbrt(V);std::cout << "A cube with a volume of " << V << " has a side length of " << side << "\n";}
This results in the following output:
A cube with a volume of 27 has a side length of 3
Codebyte Example
Use cbrt() to find the cube root of 8:
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn C++ on Codecademy
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours
- Learn C++ — a versatile programming language that’s important for developing software, games, databases, and more.
- Beginner Friendly.11 hours