Description: This program calculates sum of series of type 1/2+4/5+7/8+....
Code:
//Compiling Tool: Code::Block IDE with MinGW
//Program calculates sum of series of type 1/2+4/5+7/8+...
#include<iostream>
#include<conio.h> //for getch()
using namespace std;
int main()
{
int i,n;
float sum=0,x,a=1;
cout<<"Series Type:(1/2)+(4/5)+(7/8)+..."<<endl;
cout<<"Enter the range of n:";
cin>>n;
for(i=0; i<n; ++i)
{
x=a/(a+1);
sum+=x;
a+=3;
}
cout<<"Sum="<<sum;
getch();
}
Output:
If you want to write or construct or program C++ mini-project and do not know how or from where to start buy this simple e-book: Code Review of 26 C++ mini-projects. For book sample click this link.
Add your comments in below available comment box.
Note: Click these label/tags to view all related posts. Tags: C++Code
…till next post, bye-bye & take care.
No comments:
Post a Comment