C++ program to find the sum of series 1+1/2^2+1/3^3+…..+1/n^n

Program

#include<iostream.h>
#include<conio.h>
#include<math.h>

void main()
{
clrscr();
double sum=0,a;
int n,i;
cout<<“1+1/2^2+1/3^3+…..+1/n^n”;
cout<<“nEnter value of n:”;
cin>>n;

for(i=1;i<=n;++i)
{
a=1/pow(i,i);
sum+=a;
}

cout<<“Sum=”<<sum;
getch();
}

Output

C++ program to find the sum of series 1+1/2^2+1/3^3+…..+1/n^n

Leave a Comment

error: Alert: Content is protected!!