Popular Tutorials
Start Learning CCertification Courses
Created with over a decade of experience and thousands of feedback.
Python online compiler
JavaScript online compiler
SQL online compiler
Java online compiler
HTML online compiler
C online compiler
C++ online compiler
C# online compiler
PHP online compiler
Swift online compiler
Kotlin online compiler
TypeScript online compiler
Go online compiler
Rust online compiler
Scala online compiler
Dart online compiler
R online compiler
Ruby online compiler
C log()
The log() function computes the natural logarithm of an argument.
C log() Prototype
double log( double arg );
The log() function takes a single argument and returns a value of type float.
[Mathematics] logex = log(x) [In C programming]
It is defined in <math.h> header file.
In order to find the log() of long double or float numbers, you can use the following prototype.
long double logl( long double arg); float logf(float arg);
C log() Arguments
| Argument | remarks |
|---|---|
| arg > 0 (Greater than zero) | Finds the natural log of the argument |
| arg < 0 (Less than zero) | Shows run-time error |
Example: C log() function
#include <stdio.h>
#include <math.h>
int main()
{
double num = 5.6, result;
result = log(num);
printf("log(%.1f) = %.2f", num, result);
return 0;
}
Output
log(5.6) = 1.72
Did you find this article helpful?