Question
I am suppose to create a code that uses the pow function in math.h to calculate the hyperbolic cosine when the user inputs an angle x. the equation I have to use is cosh x= e^x + e^-x /2 can someone check my code. I am not sure what i am doing wrong. do I have to declare the constant e as a variable. I am totally lost!
#include <stdio.h>
#include <math.h>
int main (void)
{
//Local Declarations
float angleX; // Angle inputed by the user
//Statements
printf ("\nEnter angle in degrees:");
scanf ("%f", &angleX);
//Results
printf ("\nCalculation1 : (M_E^angleX + M_E^(-angleX))/2 = %f\n", pow(M_E,angleX)); /* calculates
the hyperbolic cosine using the pow function*/
return (0);
}//main
#include <stdio.h>
#include <math.h>
int main (void)
{
//Local Declarations
float angleX; // Angle inputed by the user
//Statements
printf ("\nEnter angle in degrees:");
scanf ("%f", &angleX);
//Results
printf ("\nCalculation1 : (M_E^angleX + M_E^(-angleX))/2 = %f\n", pow(M_E,angleX)); /* calculates
the hyperbolic cosine using the pow function*/
return (0);
}//main
Answers
#include <stdio.h>
#include <math.h>
int main (void)
{
//Local Declarations
float angleX; // Angle inputed by the user
float coshx; // hyperbolic cosine of angle x
//Statements
printf ("\nEnter angle in degrees:");
scanf ("%f", &angleX);
//Calculations
coshx = (pow(M_E,angleX) + pow( M_E,-angleX))/2;//calculated the hyperbolic cosine using the pow function
//Results
printf ("\nCalculation1 : = %f\n", coshx);
return (0);
}//main
#include <math.h>
int main (void)
{
//Local Declarations
float angleX; // Angle inputed by the user
float coshx; // hyperbolic cosine of angle x
//Statements
printf ("\nEnter angle in degrees:");
scanf ("%f", &angleX);
//Calculations
coshx = (pow(M_E,angleX) + pow( M_E,-angleX))/2;//calculated the hyperbolic cosine using the pow function
//Results
printf ("\nCalculation1 : = %f\n", coshx);
return (0);
}//main
I changed some things and now it is atleast coming out with a calculation but it is the wrong answer
Hmm. Looks good to me. Can you produce the results for a few values of x?
Do you at least get cosh(0) = 1.0 ?
Do you at least get cosh(0) = 1.0 ?
Related Questions
Our teacher wanted us to set up a command button that gives 3 input boxes on city, state, and zip co...
If you were given the following scores for math classes, calculate the student's GPA using a standar...
What is the purpose of tools such as Mole and sqlninja?
(1 point)
Responses
to create SQL cod...
What is the purpose of function in computer code?
to convert constants to variables
to convert int...