What is logf in C?
The logf function calculates the natural logarithm ( or ) 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, 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 ©2026 Educative, Inc. All rights reserved