Find Cube root of a number using Log function | C ++ program to Find Cube root of a number using Logarithm ; Function to find the cube root ; calculate the cube root ; Return the final answer ; Driver code
#include <bits/stdc++.h> NEW_LINE double cubeRoot ( double n ) { double ans = pow ( 3 , ( 1.0 / 3 ) * ( log ( n ) / log ( 3 ) ) ) ; return ans ; } int main ( ) { double N = 8 ; printf ( " % .2lf ▁ " , cubeRoot ( N ) ) ; return 0 ; }