Here is a quick question that should be easy to answer. Is there a cubed root function in the C++ library?

Recommended Answers

All 3 Replies

No, there isn't.

Ok, I feel pretty stupid asking this, but how would I find the cubed root of a variable? :o

A forum search for "cube root" will give you only a few hits. In one of them you might find me posting code that looks suspiciously like this:

#include <cstdlib>
#include <cmath>
#include <iostream>

int main()
{
  int val;

  std::cout<<"Enter a number: ";
  
  if ( std::cin>> val ) {
    std::cout<<"Cube root of "<< val <<": "
      << std::pow ( std::abs ( val ), 1.0 / 3.0 ) <<std::endl;
  }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.