Problem: The Taylor series of a function f(x) about a is given by f(x) = f(a) + (x-a) f(1)(a) + [(x-a)2/2! ] f(2)(a) + [(x-a)3/3! ] f(3)(a) + ... + (x-a)n/n! f(n)(a) + ...Here n is the number of terms of the Taylor series expansion and f(n)(a)is the n-th derivative of the function f(x) evaluated at x = a. This formula (with only finitely many terms) is very accurate for x close to a.Write a C++ program that takes a, x, and n as inputs from the user and evaluates the Taylor expansion of f(x) = sin x about a up to n terms. The program should also compute the relative absolute error between the value of the Taylor expansion (let us call it ea) w.r.t. the true value which is sin(a). The formula for this is |ea - sin (a)| / |sin(a)|.The program should print the value of the Taylor expansion as well as the relative absolute error. 

Input Format - a - non zero real number, x,and an integer n
Output Format - 
Floating point numbers for the values of the Taylor expansion and the relative error
Please use before printing the approximated value and the error.
cout << fixed;      // uses fixed floating point representation
cout.precision(6);  // print six digits after the decimal point

Constraints
a not equal to zero
n is a positive integer
For higher accuracy, it is advisable for x to be close to a

Sample input and output a = pi/3 , x = pi/3 + 0.001, sin(x) is approximately 0.8

Input           1.047 1.048 100
Output            0.866426 0.000577

Note:Do not write any C++ statements for printing general messages. For example, the following should NOT be present in your program:cout << "Enter a number:",cout << "The computed answer is", etc.cout should be used to print only the computed final output. In addition, do not print unnecessary spaces unless specified in the questionPlease use cout << fixed; before printing the approximated value and the error.The solution file name should be an A_Q1.cpp

Student submission:
#include<simplecpp>
#include<cmath>
main_program
{int k,n;float dfx;float x,a,q;int facval=1;float taylor=0;

const float pi=3.1412;
cin>>a>>x>>n;

for(int k=0;k<=n;k++)
{



if (k%4==0)
{
dfx=sin(x);
cout << fixed;      // uses fixed floating point representation


cout.precision(6);  // print six digits after the decimal point



cout<<dfx<<endl;
}

else if(k%4==1)
{
dfx=cos(x);
cout << fixed;      // uses fixed floating point representation


cout.precision(6);  // print six digits after the decimal point




cout<<dfx<<endl;
}

else if(k%4==2)
{
dfx=-1*sin(x);
cout << fixed;      // uses fixed floating point representation


cout.precision(6);  // print six digits after the decimal point




cout<<dfx<<endl;
}


else if (k%4==3)
{
dfx=-1*cos(x);
cout << fixed;      // uses fixed floating point representation


cout.precision(6);  // print six digits after the decimal point


cout<<dfx<<endl;
}

for(;k>0;k--)
{
facval=facval*k;
}


q=(dfx* pow((x-a),k))/facval;

taylor=sin(a)+q;
break;}
cout << fixed;      // uses fixed floating point representation
cout.precision(6);  // print six digits after the decimal point


cout<<taylor;
}

Grading criterion: Is relative absolute error calculated ?
Rating A: If correctly calculated
Rating B: If wrong
Rating C: 0
Rating D: 0
Assigned grade: B