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 | edit source]

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 | edit source]

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

return value[edit | edit source]

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 | edit source]

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

Return value'[edit | edit source]

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

example program[edit | edit source]

 
 #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 | edit source]

  • cpluspluse, cpluspluse. "math:log". cplusplus. cplusplus. Retrieved 30/9/2011. {{cite web}}: Check date values in: |accessdate= (help)