Answer to Question #251795 in C++ for aneeza riaz

Question #251795

Find and display the values of both sides of the following mathematical series expression and

an absolute difference of both sides. User can input either of angles in degree 90, 60, 30 etc.


sin(x) = x −

x

3

3!

+

x

5

5!

x

7

7!

+

x

9

9!


1
Expert's answer
2021-10-16T01:43:50-0400
#include <iostream>
#include <cmath>


using namespace std;


long getFactorial(int n) {
    int c;
    long factr = 1;
    for (int c = 1; c <= n; c++) {
        factr = factr * c;
    }
    return factr;
}


int main()
{
    double x =90;
    double res;
    res = sin(x);
    cout<<"\nResult 1: "<<res;
    double a, b, c, d;
    a=(pow(x,3)/getFactorial(3));
    b=(pow(x,5)/getFactorial(5));
    c=(pow(x,7)/getFactorial(7));
    d=(pow(x,9)/getFactorial(9));
    double res2=x-a+b-c+d;
    cout<<"\nResult 2: "<<res2;
    
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS