How can i find cubit root?
You mean Cube root?
1 2 3 4 5 6 7 8 9 10 11 12
|
template<typename T>
T CubeRoot(T param)
{
return param >> 3;
}
int main()
{
cout << CubeRoot<int>(27);
cin.ignore();
return 0;
}
|
Program output:
cube root of 27 is 3 :)
Last edited on
@codekiddy, why did you use cin.ignore();
when there was no cin?
I think he mean we should ignore his answer.
Not sure if that was a serious answer. There is a function in file <cmath> called 'pow' which can be used to find a cube root.
I alreadt found it. Pow can only power them but cant take roots. n-th root comes from here exp(log(abs(x))/n))
nth root from x.
Cube root using std::pow looks like this one:
pow(27, 1 / 3.f);