Q:

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

0

Logic :- 

As we can see the the dividend of the given series is increase by 3 each time and divisor is also increasing by 3 but divisor = dividend+1 so according to the series we can use for loop 

Logic is Given Below .
 
for(i=0;i<n;++i)
{
x=a/(a+1);
sum+=x;
a+=3;
}

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include<iostream>
using namespace std;
int main()
{
 int i,n;
 float sum=0,x,a=1;

 cout<<"\n1/2+4/5+7/8+……'\n";
 cout<<"\nEnter The Number of Terms \n";
 cin>>n;

 for(i=0;i<n;++i)
 {
  x=a/(a+1);
  sum+=x;
  a+=3;
 }

 cout<<"\n Sum = "<<sum<<endl;
 return 0;
}

 

Output:

1/2+4/5+7/8+……'

Enter The Number of Terms 

3

 Sum = 2.175

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C++ Program To Find Sum Of The Given Series 1+x^1+... >>
<< C++ Program To Find Sum Of The Given Series x+x^2/...