tanh C Library Function

The function double tanh(double x); returns the hyperbolic tangent of x radians.

Function prototype of tanh

double tanh(double x);
  • x : A floating point value representing an angle in radians.

Return value of tanh

It returns the hyperbolic tangent of x.

C program using tanh function

The following program shows the use of tanh function to calculate hyperbolic tangent of an angle in radian.

tanh C Library Function

#include <stdio.h>
#include <math.h>
 
int main(){
    double value, radian;
    printf("Enter a number\n");
    scanf("%lf", &radian);
     
    value = tanh(radian);
    printf("The hyperbolic tangent of %lf is %lf\n", radian, value);
         
    return 0;
}

Output

Enter a number
0.5
The hyperbolic tangent of 0.500000 is 0.462117