Signup/Sign In

C++ Program To Find Sum Of Series 1 / 2 + 4 / 5 + 7 / 8 + . . . . . . . . .n

Here, in this tutorial, we will be seeing how to write the program for the given pattern and at the end print the resultant sum of the series formed for the input number of terms by the user.

C++ Program To Print The Sum of The Pattern

#include<iostream>
#include<conio.h>
using namespace std;

void main()
{
int i,n;
float sum=0,x,a=1;

cout<<“1/2+4/5+7/8+……”;
cout<<“How many terms(ex: 1,2,3…n)?”;
cin>>n;
for(i=0;i<n;++i)
{
x=a/(a+1);
sum+=x;
a+=3;
}

cout<<“Sum=”<<sum;
}


1/2+4/5+7/8+……
How many terms(ex: 1,2,3…n)?
2
Sum = 1.3

Conclusion

That sums up this article detailing one program, each in C++ , to find the sum of the series 1 / 2 + 4 / 5 + 7 / 8 + . . . . . . . . .n. There can be different programs for calculating for other variations of the series.