Computer Science, asked by sumaiyamansoor2000, 8 months ago

Write a program that takes as input two numbers n (integer) and x (double), and prints cos(x) evaluated by taking n terms of the Taylor series (using x0 =0):
cos(x)=1−x2/2!+x4/4!−x6/6!...

Answers

Answered by vedant47070
0

Answer:

in which program we make the destroyer series

Answered by soumahitech
0

Answer:

# include<iostream>

using namespace std;

int main()

{

 

 int n;

 double x,i,j,fact,sign=-1,p,sum=0;

 cin>>n;

 cin>>x;

 for(i=2;i<=n;i=i+2){

  p=1;fact=1;

  for(j=1;j<=i;j++){

   p=p*x;

   fact=fact*j;

  }

  sum+=sign*p/fact;

  sign=-1*sign;

   

 }

 cout<<sum+1;

 return 0;

 

 

}

Explanation:

Similar questions