sinh()

We will get hyperbolic sin or cos or tan ) value of any number by using sinh() , cosh() or tanh() function.
sinh(x) 

Example sinh()

#include <stdio.h>
#include <math.h>
int main(void){
     float  x,ret;
     x=3.5;
     ret=sinh(x);
     printf("sinh(%.1f)=%.2f",x, ret);
     return 0;
}
The above code will give this output.
sinh(3.5)=16.54 

Example cosh()

#include <stdio.h>
#include <math.h>
int main(void){
     float  x,ret;
     x=2.54;
     ret=cosh(x);
     printf("cosh(%.2f)=%.2f",x, ret);
     return 0;
}
Output
2.54=6.38

Example tanh()

#include <stdio.h>
#include <math.h>
int main(void){
     float  x,ret;
     x=5.34;
     ret=tanh(x);
     printf("tanh(%.2f)=%.2f",x, ret);
     return 0;
}
Output
tan(5.34)=1.00

Example: Hyperbolic Sine with User Input

#include <stdio.h>
#include <math.h>
int main(void){
    float x, ret;
    printf("Enter a number: ");
    scanf("%f", &x);
    ret = sinh(x);
    printf("sinh(%.2f) = %.2f\n", x, ret);
    return 0;
}
Output:
Enter a number: 3.5
sinh(3.50) = 16.54

Using Functions for Hyperbolic Calculations

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

float calculate_hyperbolic(char type, float x) {
    if (type == 's') return sinh(x);
    if (type == 'c') return cosh(x);
    return tanh(x);
}

int main(void){
    float x;
    char type;
    printf("Enter 's' for sinh, 'c' for cosh, 't' for tanh: ");
    scanf(" %c", &type);
    printf("Enter a number: ");
    scanf("%f", &x);
    printf("Result = %.2f\n", calculate_hyperbolic(type, x));
    return 0;
}
Output:
Enter 's' for sinh, 'c' for cosh, 't' for tanh: s
Enter a number: 2.5
Result = 6.05



plus2net.com






We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer