RUN


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

  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;
}

Report Error/ Suggestion

Related Posts:




CopyRight © 2020

CopyRight © 2020