Dark Mode On/Off

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

In this tutorial, we will be learning about printing the sum of an interesting pattern by using the concept of loops and some of the basic mathematical operations.

## C++ Program To Print The Sum of Series

``````#include<iostream>
using namespace std;
int findsum(int num){
double sum=0;
for(int i=1;i<=num:i++){
cout << "1/" << i << "^" << i << " +" << sum;
sum=sum+(1/(i*i));
}
return sum;
}

int main(){
int n;
cout<<"Enter the value of n , till which sum is required:-";
cin>>n;
cout<<findsum(n);
return 0;
}``````

Enter the value of n , till which sum is required:- 3
1.287037

## Conclusion

In this tutorial, we have seen how can we print the sum of the given patterns to the given term. Here as to get the more accurate answer the value of the sum is taken to be in double,a lthough it's not necessary it can be in float also.

Want to learn coding?
Try our new interactive courses.
Over 20,000+ students enrolled.