Write program c++ Write two functions to compute the values of cos x and sin x r
ID: 3680037 • Letter: W
Question
Write program c++
Write two functions to compute the values of cos x and sin x respectively using the following Taylor series (x is any positive float number represents in radian). Then, use these functions in main function to compute the following equation. Your program should ask user the following option: Press t/T for Tan x Press s/S for Sin x Press c/C for Cos x Press * for exit the program. Based on the input provided by the user, the program should ask user the value of x in radian and the value of term. Then, your program should print the result as shown in figure. Once, result is shown, the program will further show the menu as shown above until user chooses * as input to exit the program. For a wrong choice from the menu (other than t/T, s/S. c/C and *, your program should notify Wrong input and allow user to input his/her choice again). (Note: You should not use predefined sin and cos function; No points will be assigned if you use predefined sin and cos functions from math.h)
tan(x)=sin(x)/cos(x)
sin(x)=x-1/3! x^3+1/5! x^5-1/7! x^7+1/9! x^9-…
cos(x)=1-1/2! x^2+1/4! x^4-1/6! x^6+1/8! x^8-…
(Hint: Write down a function named sine with two input parameters x and no. of terms; in the above example of sin(x) there are total 5 terms shown namely x,1/3! x^3,1/5! x^5,1/7! x^7 and 1/9! x^9. Write another function named as cosine with two input parameters x and no. of terms like sine function. In the main function, get the values of x and no. of terms and use the function sine and cosine to compute the value of tan(x).) The output of the program should look like as in the figure:
Explanation / Answer
_______
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.