is the following program correct for the title 1/1!+1/3!+1/5!+.....+1/n!
#include<iostream.h>
#include<conio.h>
class series
{
int i,n,sum,fact;
public:
void input()
{
cout<<"enter the number of terms";
cin>>n;
}
void processing()
{
if(n%2==0)
{
cout<<"the number is invalid";
}
else
{
i=1,sum=0;
while(i<=n)
{
sum+=(1/factorial(i););
i+2;
}
}
}
int factorial(int lim)
{
int j;
fact=0;
for(j=1;j<=lim;j++)
fact*=j;
return fact;
}
void output()
{
cout<<"the sum of the series is"<<sum;
}
};
void main()
{
series se;
clrscr();
se.input();
se.processing();
se.output();
getch();
}
i programmed it myself!!! i think it's correct, but i wish to check all the same.. i impressed my teacher yesterday in c++ class *blushing* :) :) :P