Cube Root of Number program in C++
# Important Points:
- The std::cbrt() is an inbuilt function of <math.h> library in C++ which is used to calculate the cube root of a number.
- cbrt() function accepts a number as argument and returns the cube root of that number.
Example:
Given number: 3.4
Cube root: 1.50369
# Algorithm
- Create a variable number and ans.
- Enter the number whose cube root is to be calculated.
- Get the cube root using function cbrt()
Code:
#include <iostream>
#include <cmath>
using namespace std;
int main(){
float number, ans;
cout << "Enter any number: ";
cin >> number;
ans = cbrt(number);
cout << "\n Cube Root of " << number << " is: " << ans;
}
Report Error/ Suggestion