The C log function is one of the Math Function, used to calculate the logarithmic value of given number with base E.

In this article we will show you, How to write a log function in C Programming language with example.

## C log syntax

The basic syntax of the log inĀ C Programming is as shown below.

double log(double number);

## C log Function Example

The C math log Function allows you to find the logarithmic value of base E.

In this program, We are going to find the logarithmic value of different values, and display the output.

/* LOG in C Programming Example */ #include <stdio.h> #include <math.h> int main() { printf("\n The Logarithmic Value of 0 = %.4f ", log(0)); printf("\n The Logarithmic Value of 1 = %.4f ", log(1)); printf("\n The Logarithmic Value of 5 = %.4f ", log(5)); printf("\n The Logarithmic Value of 16.4 = %.4f ", log(16.4)); printf("\n The Logarithmic Value of -9.32 = %.4f ", log(-9.32)); printf("\n The Logarithmic Value of -15.34 = %.4f ", log(-15.34)); return 0; }

**OUTPUT**

## C log Example 2

In this example, we are allowing the user to enter their own value. Next, we used log function to find the logarithmic value of user given number with base E.

/* LOG in C Programming Example */ #include <stdio.h> #include <math.h> int main() { float number, logValue; printf(" Please Enter any Numeric Value : "); scanf("%f", &number); logValue = log(number); printf("\n Logarithmic Value of %.2f = %.4f ", number, logValue); return 0; }

**OUTPUT**

Thank You for Visiting Our Blog