Question: *to do in C* Question 2 (15 marks) Ever wonder how the standard C math functions make their calculations. This question lets you explore how

*to do in C*  *to do in C* Question 2 (15 marks) Ever wonder how
the standard C math functions make their calculations. This question lets you

Question 2 (15 marks) Ever wonder how the standard C math functions make their calculations. This question lets you explore how to compute hyperbolic cosine of any value of x, cosh(x). The following math infinite series gives the value of cosh(r): Such series serves as a basis for calculating cosh(r) in a program (i.e. in a function). To allow a computer program to calculate cosh(x), the number of terms for computing the value must be limited (it is impossible to compute an infinite number of terms). Thus the above equation is changed to ng " . Equation 2 Develop software that meets the following requirements: Prompt the user for the value of x and the number of terms, n, in the series used to compute cosh(x). o Use a function, getNumTerms, to get the value for n (the functions returns the value of n). The function must ensure that the user returns a value for n that is strictly positive (greater than 0). The main function shall call this function. Compute the value of cosh(r) using the above series and displays the results to the user o Use a function, coshyper, to compute and return the value of cosh(x)The function receives the values of x and n. In the function use a loop to compute the values of the terms of the series and accumulate the values in a variable. Given that the powers ofx,2, in the term numerator and the factorial, (21)!, in the term denominator will become very large in a very few terms, calculating the values of each term separately will quickly reach the limit of the computer o Use a strategy where the value of a term of equation 2 is calculated from the value of the previous term. The terms of the equation are numbered with i where i tarts at 0:o 2 expressed as Thus equation 2 can be where Note now that the term t, can be computed from the previous term i as follows: The above comp utation does not involve the same large numbers as the numerator/denominator of the terms in Equation 2. Note that term t is known to have the value If n is the number of terms used to calculate cosh(x), then i varies between 0 and.e. N-n in Equation 2). In the function main, prompt the user to quit the program with the message "Do you wish to quit (y)? ", and read in a character Repeat the above steps if the user enters 'n' and stop the program if the user answers 'y'. Keep prompting the user if an invalid answer is entered (i.e. the user enters a character other than 'y'or Print the message "Program terminated" when the program Respect the following guidelines: DO NOT use arrays or structures in your answer. DO NOT use standard math functions in your answer Recall that fMush function should be called before reading in a character input from the user To answer this question, please provide nThe source code to your program in a C file (DO NOT insert the source code into your assignment file, PDF file). 2) Insert the output for the following test cases into your assignment document. Include testing of bad values for n and the answer when prompting to quit. snumber of ieshs Note that the values in the above table are calculated using Excel the software may not give identical results, particularly for low value of n. The following shows a sample output that tests the above values as well as improper input. afor 1.5 lease enter real val for -15.3 lease enter a real valyt for : 5.e-3 esecut ion tiee 156.931

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!