Q:

C++ Program To Find Sum Of Series 1+1/2^2+1/3^3+…..+1/n^n

0

Logic :- 

This Below Solve this series in second ,use this statement and use it .you also can modify and see the difference 

 
Syntax :-
 
Series=1/pow(i,i);
 
After that statement you need to add all the statement .  

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include<iostream>
#include<math.h>
using namespace std;
int main()
{
 double sum=0,a;
 int n,i;

 cout<<"1+1/2^2+1/3^3+…..+1/n^n";
 cout<<"\nEnter The Value Of n :\n";
 cin>>n;

 for(i=1;i<=n;++i)
 {
  a=1/pow(i,i);
  sum+=a;
 }
 cout<<"Sum = "<<sum<<endl<<endl;
 return 0;
}

 

Output:

1+1/2^2+1/3^3+…..+1/n^n

Enter The Value Of n :

4

Sum = 1.29094

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C++ Program To Find Sum Of The Following Series 1+... >>