C tanh Function

The C tanh function is a Math Function used to calculate the Trigonometric Hyperbolic Tangent of a given value or specified expression. The syntax of the tanh is

double tanh(double number);

C tanh Function Example

The math tanh Function allows you to find the Hyperbolic Tangent of a given value. In this program, We are going to find the Hyperbolic Tangent of different values and display the output.

#include <stdio.h>
#include <math.h>

int main()
{ 
    printf("\n The Hyperbolic Tangent Value of 0      = %.4f ", tanh(0));
    printf("\n The Hyperbolic Tangent Value of 1      = %.4f ", tanh(1));
    
    printf("\n The Hyperbolic Tangent Value of 1.25   = %.4f ", tanh(1.25));
    printf("\n The Hyperbolic Tangent Value of 2.59   = %.4f ", tanh(2.59));
    
    printf("\n The Hyperbolic Tangent Value of -0.23  = %.4f ", tanh(-0.23));
    printf("\n The Hyperbolic Tangent Value of -4.32  = %.4f ", tanh(-4.32));
    
    return 0;
}
C tanh Example

tanh Example 2

In this C Programming example, we are allowing the user to enter their value. Next, this program uses the tanh function to find the hyperbolic tangent of a user given number.

#include <stdio.h>
#include <math.h>

int main()
{
    float number, tanhValue;

    printf(" Please Enter any Numeric :  ");
    scanf("%f", &number);
  
    tanhValue = tanh(number);
  
    printf("\n Hyperbolic Tangent of %.2f = %.4f ", number, tanhValue);
  
    return 0;
}
 Please Enter any Numeric :  -2.347

 Hyperbolic Tangent of -2.35 = -0.9819