// Example program
#include <iostream>
#include<cmath>
usingnamespace std;
int main()
{
int factorial(int);
double s=-2;int n,fact,x;
cout<<"Enter the no. of terms of series :";
cin>>n;
cout<<"Enter the value of x: ";
cin>>x;
for(int i=1;i<=n-1;n++)
{
fact=factorial(i*2);
if(i%2==0)
{
s=s-(pow(x,i)/fact);
}
else
s=s+(pow(x,i)/fact);
}
cout<<"Sum ="<<s;
return 0;
}
int factorial(int n)
{
int f=1;
for(int i=1;i<=n;i++)
{
f=f*i;
}
return f;
}