sin(x) from Its Series, With and Without the Library
MediumRead a real number x in radians and an integer N, sum the first N terms of the series sin x = x - x^3/3! + x^5/5! - x^7/7! + ..., and print two lines: series sin(x) = 0.841471 with the sum, and library sin(x) = 0.841471 with the value from sin in <math.h>, both to six decimal places. The first term is x itself, and each later term is built from the previous one as term = -term * x * x / ((2k + 2)(2k + 3)) for k from 0. N must be between 1 and 100; otherwise print N must be between 1 and 100 and return 1. If x and N cannot be read, print invalid input and return 1.
Success Criteria
Your code must pass 7 test case(s) to complete this exercise. 3 hint(s) are available if you need help.
Sign in to track your progress
You can work on exercises as a guest, but sign in to track your progress and save your submissions.
How did you find this exercise?
Your rating helps us improve the content.