I need help with this assignment. It seems fairly simple, but I cannot figure it
ID: 3569982 • Letter: I
Question
I need help with this assignment. It seems fairly simple, but I cannot figure it out. The program must be written in C++ (NOT C), we are not allowed to use getch; or headers associated with it as it is deprecated.
I have a final over information similar to this tomorrow morning, so I would greatly appreciate help ASAP. I know the program seems long, but it isn't, the description is just very detailed and includes some history. Thanks ahead of time! I'd love to see how someone goes about figuring this out.
Explanation / Answer
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int N;
double PI;
PI=atan(1)*4;
cout<<" enter value of N ";
cin>>N;
double sum_new=0.0;
double sum_old=0.0;
double error=0.0;
int i;
cout<<endl<<"value of N"<<" calculated value"<< " actual value";
for(i=0;i<N;i++)
{
sum_new=sum_old+pow(-1,i)*4/(2*i+1);
error=(sum_new-PI)*100/PI;
cout<<endl<<i<<" "<<sum_new<<" "<<error;
sum_old=sum_new;
}
}