77 976
Assignments Done
Successfully Done
In August 2019

Answer to Question #39886 in C++ for peter

Question #39886
using the series definition of e^+-jx,
develop an algorithm using pseudocode for computing cos(x) and sin(x)
use a sentinel controlled while loop
your accuracy should be at least to two decimal please help me out i need the solution for submission before monday, please
Expert's answer
#include <iostream>
#include <math.h>

using namespace std;

const long N=12;
#define M_PI 3.1415926535897932384626433832795

// Module
double mabs(double x)
return (x>0)?x:-x;

// The degree x^y
double mpow(double x, long y)
double r = 1;
while((y--)>0) r*=x;
return r;

// Factorial x!
long fact(long x)
if (x<=1) return 1;
else return x*fact(x-1);

// Sinus series
double seq_sin(double x)
double r = 0;
for(long n=0;n<N;n++) {
return r;

// Cosine series
double seq_cos(double x)
double r = 0;
for(long n=0;n<N;n++) {
return r;

void main()
cout << "sin(pi/5)=" << sin(M_PI/5) << endl;
cout << "seq_sin(pi/5)="<< seq_sin(M_PI/5) << endl;
cout <<endl;
cout << "cos(pi/5)=" << cos(M_PI/5) << endl;
cout << "seq_cos(pi/5)="<< seq_cos(M_PI/5) << endl;


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!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions