# C Programming/C Reference/math.h/log

Jump to: navigation, search

## Logarithmic function in 'c' language

these functions are under math.h. In general log(x) i.e ln(x) and log10(x) these are two types of logarithm.In C language function is available for both of these. so that we can use mathematical terms effectively. log(x) is natural logarithm. log10 is base 10.

### 1.log/ln

`````` double log (double x);<\code>
float log (double x);<\code>
long double log (long double x); <\code>
```
```

#### `return value`

`return the natural logarithm of x.`

``````         the natural logarithm is the base-e logarithm.
the inverse of the natural exponential function.
```
```

### `example program`

``````1
2
3
4
5
6
7
8
9

#include <stdio.h>
#include <math.h>
int main() {
double vrbl, result;
vrbl = 5.5;
result = log (vrbl);
printf("ln(%lf) = %lf\n", vrbl, result );
return 0;
}

ref name=cplusplus group=cplusplus>cplusplus, cplusplus. "clibrary(math.h)". http://www.cplusplus.com/reference/clibrary/cmath/log/. Retrieved 30/09/11. </ref>
```
```

### 2. log10

`````` double log10 (double x);<\code>
float log10 (double x);<\code>
long double log10 (long double x); <\code>
```
```

#### `Return value`

`compute common logarithm return the common(base - 10) logarithm of x, where x>0.`

### `example program`

``````1
2
3
4
5
6
7
8
9

#include <stdio.h>
#include <math.h>
int main() {
double vrbl, result;
vrbl = 100;
result = log10 (vrbl);
printf("log10(%lf) = %lf\n", vrbl, result );
return 0;
}
```
```

## Notes

• cpluspluse, cpluspluse. "math:log". cplusplus. cplusplus. Retrieved 30/9/2011.