log() - Mathematical Function
How is Mathematical Function "log()" used in C++?
How to find the natural logarithm value of a number?
is a Mathematical Function that returns the natural logarithm for the given "num". This function triggers a domain error when the "num" is negative and a range error occurs if the "num" is zero.
Syntax to find Natural Logarithm :
float log( float num );
double log( double num );
long double log( long double num );
cout << "Log of 2 is:: " << log(2) << endl;
cout << "Log of 4 is:: " << log(4) << endl;
Log of 2 is:: 0.693147
Log of 4 is:: 1.38629
In the above example log() is used to find the natural logarithms of 2 and 4.