#include<iostream.h>
#include<conio.h>
//why did u have to give the inside a class .....why not just a fun.
class abc
{ public:
// u r returning a float value right...
float facto(int num)
{ clrscr();
// though u store the value 1/fact in a float variable 1/fact will be int...if fact is int
float fact=1;
while(num)
{fact*=num;
--num;}
float i=1/fact;
// why print hear???....no prob though
cout<<i;
//......why did u return 0.....
return i;
}
};
void main()
{
abc o;
float sum=1;
int number=1;
//....when do u want to see the ans........
while(number<22)
{ sum+=o.facto(number);
++number;
}
cout<<sum;
}
// it will be better if u post the code not as an image
#include<iostream.h>
#include<conio.h>
//why did u have to give the inside a class .....why not just a fun.
class abc
{ public:
// u r returning a float value right...
float facto(int num)
{ clrscr();
// though u store the value 1/fact in a float variable 1/fact will be int...if fact is int
float fact=1;
while(num)
{fact*=num;
--num;}
float i=1/fact;
// why print hear???....no prob though
cout<<i;
//......why did u return 0.....
return i;
}
};
void main()
{
abc o;
float sum=1;
int number=1;
//....when do u want to see the ans........
while(number<22)
{ sum+=o.facto(number);
++number;
}
cout<<sum;
}
// it will be better if u post the code not as an image