write programs to evaluate the following to 0.0001% accuracy.
/* write programs to evaluate the following to 0.0001%
accuracy.
(B) SUM = 1+[(1/2)raise to 2]+[(1/3)raise to 3]+.....*/
#include
#include
#include
void main()
{
clrscr();
int num;
cout<<"Enter the number:- ";
cin>>num;
float r,sum=0,p;
int k,i;
for(k=1,i=1;i<=num;i++,k++)
{
r=1.0/k;
p=pow(r,i);
sum=sum+p;
}
cout<<"\n\nSUM = " << sum;
getch();
}