# Write a Program in C++ & Python to find the Sum of Series 1/2+4/5+7/8+…

By | September 7, 2019

Here in this program, we will code to find the sum of series 1/2+4/5+7/8+…. Here n represents the total number of terms we want to add.

C++ program to find the sum of series 1/2+4/5+7/8+…

```#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
int i,n;
clrscr();
float sum=0,s,t=1;
cout<<"Calculate the sum of series 1/2+4/5+7/8+\n";
cout<<"Enter the number of terms you want to add: ";
cin>>n;
for(i=0;i<n;++i)
{
s=t/(t+1);
sum+=s;
t+=3;
}
cout<<"The Sum is: "<<sum;
getch();
}```

Output:

```Calculate the sum of series 1/2 +4/5 +7/8...

Enter the number of terms you want to add: 5
The sum is: 4.01266233```

### Python Program to find the Sum of Series 1/2+4/5+7/8+…

```import math
sum=0
t=1
print("Calculate the sum of series 1/2 +4/5 +7/8....")
n = int(input("Enter the number of terms you want to add: "))
for i in range(n):
s=t/(t+1)
sum+=s
t+=3
print("The sum is:", sum)```

Output:

```Calculate the sum of series 1/2 +4/5 +7/8...

Enter the number of terms you want to add: 6
The sum is: 4.9538```