#include<iostream.h>
#include<conio.h>
class summation
{
double sum;
public:
void s();
};
void summation::s()
{
sum=0;
int n;
cout<<"enter the number of terms whose sum you want in the
series"<<endl;
cin>>n;
for(int
i=1;i<=n;i++)
{
sum=sum+(1/(double)i);
}
cout<<"the sum is :"<<sum;
}
void main()
{
clrscr();
summation obj;
obj.s();
getch();
}
Comments
Post a Comment