English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
double log(double x) returns the natural logarithm of x (base e logarithm).
double log(double arg);
The log() function takes a single parameter and returns the value of type float.
It is in<math.h>Defined in the header file.
To find the natural logarithm of long double or float, the following prototype can be used.
long double logl(long double arg); float logf(float arg);
Parameter | Description |
---|---|
arg > 0 (greater than zero) | Calculate the logarithm of a natural number |
arg < 0 (less than zero) | Display runtime errors |
#include <stdio.h> #include <math.h> int main() { double num = 5.6, result; result = log(num); printf("log(%.1f) = %.2f", num, result); return 0; }
Output Result
log(5.6) = 1.72