log in c

What is log in c programming?

log in c is a library function which is used to calculate logarithm value of a given number.

This function is defined in math.h header file.

Prototype

double log(double m);

Parameters

log function takes double type value as input parameter.

Return value

log function returns logarithm value of given number.


Example program for log in c

#include<stdio.h>
#include<math.h>
int main()
{
  double i,res;
  printf("Enter the double type number \n");
  scanf("%lf",&i);
  res=log(i);
  printf("The logarithm value is %lf \n",res);
  return 0;
}
Example for log in c programming
Example for log in c programming

Code explanation

The logarithm value of a given number is found by calling log function and result is printed on to console.

log() Man page


Difference between log and log10 in c

log in c is a library function that is used to calculate the logarithm value of a given number. log10 in c is used to calculate the common base10 logarithm value of a given number.

Prototypes are as follows

double log(double m);

double log10(double m);
log( )log10( )
Used to calculate logarithm value of a given number.Used to calculate common base10 logarithm value of given number.
double log(double m);double log10(double m);

People also ask for

What is log in c?

log in c is a library function that is used to calculate the logarithm value of a given number.