You are here

log function

log function returns natural logarithm (base is e) of a number, where e is the exponential number.

Declaration: double log(double);

C programming code for log

#include <stdio.h>
#include <math.h>
int main()
  double n, result;
  printf("Enter a number to calculate it's natural log (base is e)\n");
  scanf("%lf", &n);
  result = log(n);
  printf("Natural log of %.2lf = %lf\n", n, result);
  return 0;

Output of program:
log math.h c programming