#include<iostream> #include<cmath> using namespace std; int nfact=1, k, x; doubl
ID: 3657211 • Letter: #
Question
#include<iostream>
#include<cmath>
using namespace std;
int nfact=1, k, x;
double sinvalue,j,d, sin = 0;
for(int i = 0; i<10; i++){
j = pow(-1,i);
k=( (2*i)+1);
d= pow(x,k);
nfact=1;
do
{
nfact = nfact*k;
k--;
}while(k > 0);
sinvalue=(( j)/nfact)*d;
sin= sinvalue +sin;
}
cout<<"The sin value is "<<sin<<endl;
}
int main(){
Please help me debug my code so that it outputs the correct value for sine in radians when the user inputs the angle. I intend to use cmath library for pow function only. when I enter the angle wrong results are outputed i.e if I input 2 for example I get 0.904048 radians instead of 0.909297 radians. The error increases as I input larger angles. what am i doing wrong?