C Programming/math.h/log
< C Programming | math.h
Logarithmic function in 'c' language
editthese 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
editdouble log (double x);
float log (double x);
long double log (long double x);
return value
editreturn 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
editdouble log10 (double x);
float log10 (double x);
long double log10 (long double x);
Return value'
editcompute 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- cpluspluse, cpluspluse. "math:log". cplusplus. cplusplus. Retrieved 30/9/2011.
{{cite web}}
: Check date values in:|accessdate=
(help)