C++ program to print the cube root of a number. Using this program to print we can execute the C++ program with cube root function. The cube root of a number an is the number that, when multiplied three times, yields the number ‘a’. As a result, 3125 = 5 is the cube root of 125.

#include <iostream>

#include <cmath>

using namespace std;

int main()

{

float num, ans;

cout << "Enter the num";

cin >> num;

ans = cbrt(num);

cout << "\n Cube root of " << num << " is: " << ans;

}

Output:

Enter the num 5

Cube root of 5 is: 1.70998

## What is cmath function in c++ program

The cmath> header file in C++ provides a set of functions for performing mathematical operations, such as sqrt() for calculating the square root, log() for finding the natural logarithm of a number, and so on.

## What is cbrt() function in c++ program

std::cbrt() is a built-in function in the C++ STL that calculates the cube root of an integer. It takes an integer as an argument and returns the number’s cube root. A number’s cube root is a value that, when multiplied by itself three times, returns the original value. For example, the cube root of 27, written as 327, is 3, because we get 3 x 3 x 3 = 27 = 33 when we multiply 3 by itself three times.