C Programming/math.h/log

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Logarithmic function in 'c' language[edit]

these functions are under math.h. In general log(x) i.e ln(x) and log10(x) these are two types of logarithm.In C language function is available for both of these. so that we can use mathematical terms effectively. log(x) is natural logarithm. log10 is base 10.

1.log/ln[edit]

 double log (double x);
 float log (double x);
 long double log (long double x); 

return value[edit]

return the natural logarithm of x. The natural logarithm is the base-e logarithm, the inverse of the natural exponential function.

#include <stdio.h>
#include <conio.h>
void main()
{
    
    int num a,b,c,d;
    
    
    clrscr();
    
    printf("\n\tadddtion of 1 ");
    
    scanf("%d",&a);
    
    printf("\n\tsubtraction of 2");
    
    scanf("%d",&b);
    
    printf("\n\tmutiplication of 3");
    
    scanf("%d",&c);
    
    printf("\n\tdivide of 4");
    
    scanf("%d",&d);
    
    
    getch();
    
}

log10[edit]

 double log10 (double x);
 float log10 (double x);
 long double log10 (long double x); 

Return value'[edit]

compute common logarithm and return the common(base - 10) logarithm of x, where x>0.

example program[edit]

 
 #include <stdio.h>
 #include <math.h>
 int main() {
      double vrbl, result;
      vrbl = 100;
      result = log10 (vrbl);
      printf("log10(%lf) = %lf\n", vrbl, result );
      return 0;
 }

Notes[edit]