cpp code
cpp code
#include <iomanip>
using namespace std;
double value;
return a;
}
int main() {
cout << "Enter a value: ";
cin >> value;
if (value < 0) {
// For negative values, calculate the cube root of the absolute value and
negate the result
double positive_root = root(-value); // Take the cube root of the absolute
value
cout << "The cube root of " << value << " is: " << setprecision(15) << -
positive_root << endl;
} else {
// For non-negative values, calculate the cube root
cout << "The cube root of " << value << " is: " << setprecision(15) <<
root(value) << endl;
}
return 0;
}