Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please solve it quickly In addition to the cos' pre-defined function, which is found in the 'cmath' library, the cosine of an angle 'x' (given
Please solve it quickly
In addition to the cos' pre-defined function, which is found in the 'cmath' library, the cosine of an angle 'x' (given in radians), can be estimated using the following series: (-1) cos(x) -72k (2k)! k=0 The series can be written as: 78 cos(x) = 1 x2 + 2! + 6! 4! 8! Write a C++ program that reads a list of angles (in degrees) and the values of k (k represents the number of terms in the above series) from an input file called (input.txt). The program should only accept angles between 0 and 180. When invalid angle is read from the file, an error message should be displayed (see the given sample output) The program should include the following user-defined functions: 1. Function 1 is called factorial, which is used to compute the factorial to be used in the above series. 1. Function 2 is called series, which is used to compute the estimated cosine as given by the above series and calculate the Error Marign (difference between cos(x) given by cmath and the estimated cos(x) based on the given series) and send the program outputs to another file called (output.txt) as shown below. Hint: Use the same given data in the input file to check your code. Do not use materials that we did not teach you such as struct, pointers, and 2-d arrays input.txt 100 5 3 25 33 190 50 86 3 4 3 4 output.txt X 100 25 33 190 50 86 COSStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started