log()


The log function returns the logarithm of x to the base of e.

Sample Program:

/*
Write a program to illustrate log math function of C.
*/


#include<stdio.h>
#include<math.h>

main(){
 double number, result;
 printf("Enter a number(base is e)   ");
 scanf("%lf",&number);
 result = log(number);
 printf("Natural log of %lf = %lf", number, result);
 return 0;
}

Output:

Enter a number(base is e) 10
Natural log of 10.000000 = 2.302585
  

Post a Comment

0 Comments