# Library Function Math h log()

## Log() library function in Math

The `log()` function is a mathematical function that is used to calculate the natural logarithm of a number. In programming, the `log()` function is often found in the `math` library in various programming languages. Here is the theory of how the library function h log() in C is used.The C log() function enumerates the natural logarithm of an argument.

### Library Function Math h log()

In C, the `log()` function is used to compute the natural logarithm of a number. The natural logarithm is the base-e logarithm, which is the inverse of the `exp()` function. The `log()` function is declared in the `math.h` header file, so you’ll need to include that in your program in order to use the `log()` function.

Here is an example of how to use the `log()` function in C:

Run
```#include<stdio.h>
#include<conio.h>
int main()
{
double x = 2.0;
double y = log(x);
printf("The natural logarithm of %f is %f\n", x, y);
return 0;
}
```

### Output

`The natural logarithm of 2.000000 is 0.693147`

### Some facts about Clog() function

In C, the `log()` function is a part of the math library and can be used to calculate the natural logarithm of a number. To use the `log()` function in C, you will need to include the `math.h` header file at the top of your program.

The `log()` function takes a single argument, which is the number for which you want to calculate the natural logarithm. The function returns a double-precision floating-point value that represents the natural logarithm of the input number.

It’s worth noting that the `log()` function can only be used with positive numbers. If you pass a negative number or zero to the `log()` function, it will return `-inf` (negative infinity).

### C log() Arguments

The `log()` function in C takes a single argument, which is the number for which you want to calculate the natural logarithm. The argument must be a double-precision floating-point value.

Here is the syntax for the `log()` function in C:

`double log(double x);`

The argument x is the number for which you want to calculate the natural logarithm. It must be a double-precision floating-point value.

### Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

## Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others