C++ program to find cube root of a number

Program to find Cube Root of Number 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

  1. Create a variable number and ans.
  2. Enter the number whose cube root is to be calculated.
  3. 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; }