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

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

#include<iostream.h>
#include<conio.h>

void main()
{
clrscr(); //to clrscr the screen
int i,n;
float sum=0,x,a=1;

cout<<“1/2+4/5+7/8+……”;
cout<<“nnHow many terms(ex: 1,2,3…n)?”;
cin>>n;

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

cout<<“nSum=”<<sum;
getch(); //to stop the screen
}

Leave a Reply

Your email address will not be published. Required fields are marked *