log function in C programming language
- Home
- function in C
- log function in C programming language
- On
- By
- 0 Comment
- Categories: function in C, pre-define maths function in C
log function in C programming language
log function in C programming language
In this tutorial, we will discuss log function in the C programming language
Description
In the C programming language, the log() Arithmetic function returns the logarithm of x to the based of e
log(): In C programming Language,log() is used to perform calculate natural logarithm of significant value
Declaration
The Syntax of the log() in C Programming language
double log(double x);
Parameters or Arguments
X is the parameter or argument of this function which is used in the calculation of the logarithm of x to the base of e
Returns
The log function returns the logarithm of x to the base of e
Required Header
In this Language, the required header file for log() is
#include<math.h>
log function in C
Example
The following example shows the usage of the log()
Program 1
#include <stdio.h> #include <math.h> int main() { double a=1.5,b=1.25; printf("log value of %f is: %f\n",a,log(a)); printf("log value of %f is: %f\n",b,log(b)); getch(); return 0; }
When above program me is compiled it will produce the following result
log value of 1.500000 is: 0.405465
log value of 1.250000 is: 0.223144
program 2
#include <stdio.h> #include <math.h> int main() { //define the variable double logValue; double inputValue; //get input from user printf("Please enter the value to calculate log value :"); scanf("%lf",&inputValue); //calculate the log value logValue=log(inputValue); //display the log value printf("\nlog value of %lf is %lf\n",inputValue,logValue); getch(); return 0; }
When above program me is compiled it will produce the following result
please enter the value to calculate log value :1.5 log value of 1.500000 is 0.405465
Other C programming language functions that are similar to the cosine function
suggested for you
User defined function in C language