Write a function that returns a structure containing A B of
Solution
#include<iostream>
 #include<math.h>
 using namespace std;
 //Find factorial
 double fact(double n)
 {
     double fac = 1;
    for(int c = 2; c <= n; c++)
      fac = fac * c;
     return fac;
 }
 //Series A
 double Ser1(double n, double x)
 {
     double A, p, f;
     A = x;
     for(int c = 3; c <= n; c+=2)
     {
         p = pow(x,c);
         f = fact(c);
         A = A + p / f;
     }
     return A;
 }
 //Series B
 double Ser2(double n, double x)
 {
     double B, p, f;
     B = -x;
     for(int c = 2; c <= n; c++)
     {
         p = pow(x,c);
         f = fact(c);
         //For + or - sign
         if(c % 2 == 0)
             B = B + p / f;
         else
             B = B - p / f;
     }
     return B;
 }
 int main()
 {
     double x, n;
     //Accept number of terms
     cout<<\"\  Enter the value of n: \";
     cin>>n;
     //Accept x value
     cout<<\"\  Enter the value of x: \";
     cin>>x;
cout<<\"\ A = \"<<Ser1(n, x);
    cout<<\"\  B = \"<<Ser2(n, x);
 }
 Outout:
 Enter the value of n: 5
Enter the value of x: 2
A = 3.6
 B = -0.933333

