Problem :- Write A C++ Program To Find Sum Of The Given Series 1/2+4/5+7/8+.......N
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
Try Yourself C++ Program To Find Sum Of The Given Series 1+2+3+4+5+6 . . . . n
Solution :-
Output:-
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;
}
Try Yourself C++ Program To Find Sum Of The Given Series 1+2+3+4+5+6 . . . . n
Solution :-
#include<iostream>
using namespace std;
int main()
{
//By-Ghanendra Yadav
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:-
0 Comments: