What is logf in C?

The logf function calculates the natural logarithm (logelog_e or lnln) of the argument passed, when the argument is of the float type.

Standard Library

#include<math.h>

Syntax

float logf( float number );

Parameters

str - float value.

Return Value

If no errors occur, ln numberln \space number is returned.

If a negative number is passed as an argument, an error occurs.

Code

#include <math.h>
#include <stdio.h>
int main()
{
float result;
float x = 10.2;
result = logf(x);
printf("The natural log of %f is %f\n", x, result);
return 0;
}

Free Resources

Copyright ©2024 Educative, Inc. All rights reserved