11/16/2015

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

Problem :- Write A C++ Program To Find Sum Of Series 1+1/2^2+1/3^3+…..+1/n^n .

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 .   

Solution :-

#include<iostream>
#include<math.h>
using namespace std;
int main()
{
//By-Ghanendra Yadav
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:-

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

Previous Post
Next Post

post written by:

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.
Follow Me

0 Comments: