411 REFERENCE · Wikibooks
C programming/math.h/log
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Logarithmic function in 'c' language
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
double log (double x);
float log (double x);
long double log (long double x);
return value
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 <stdlib.h>
void main()
{
int num a,b,c,d;
#ifdef __WIN32
system("cls"); // for Windows
#else
system("clear"); // for Unix and Linux
#endif
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);
getchar();
}
log10
double log10 (double x);
float log10 (double x);
long double log10 (long double x);
Return value'
compute common logarithm and return the common(base - 10) logarithm of x, where x>0.
example program
#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
cpluspluse cpluspluse math:log http://www.cplusplus.com/reference/clibrary/cmath/log/ cplusplus cplusplus 30/9/2011
deep