Header file:
math.h
Synopsis:
double log(double x);
Description:
Returns the value of natural logarithm of x.
log function C example:
#include<stdio.h>
#include<math.h>
int main() {
double input, res;
printf("Enter your input:");
scanf("%lf", &input);
res = log(input);
printf("ln(%lf) = %lf\n", input, res);
return 0;
}
#include<math.h>
int main() {
double input, res;
printf("Enter your input:");
scanf("%lf", &input);
res = log(input);
printf("ln(%lf) = %lf\n", input, res);
return 0;
}
Output:
jp@jp-VirtualBox:~/cpgms/math$ gcc log.c -lm
jp@jp-VirtualBox:~/cpgms/math$ ./a.out
Enter your input:10
ln(10.000000) = 2.302585
jp@jp-VirtualBox:~/cpgms/math$ ./a.out
Enter your input:10
ln(10.000000) = 2.302585
No comments:
Post a Comment