Function 1: Write a program that reads an angle x in radians from the keyboard.
ID: 644688 • Letter: F
Question
Function 1:
Write a program that reads an angle x in radians from the keyboard. Then, in a function, compute the cosine of the angle using the first five terms of this series. Print the value computed.
Function 2:
Start by reusing the code from function 1. However, instead of calculating just the first five terms, this time you will continue to calculate terms until a given term is > 0.0001. Make sure you print out the final result, and the number of terms used to calculate this result.
Explanation / Answer
// Pre-processor Directives #include // Required for for use of cin, cout #include // Required for use of sin, cos, pow functions // using directives using namespace std; // PROGRAM STARTS HERE! double cosine(double angle); long factorial(long n); // Declaration of the main function int main() { double angle; // Ask for user input cout > angle; // Display the result coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.