Jan 29, 2013

1/1+1/2+1/3.........program

/*1/1+1/2+1/3.........program*/

#include"stdio.h"
#include"conio.h"
void main()
{
clrscr();
int i=1;
unsigned long Fact=1;
float s1=0.0,s2=1.0;
do
{
s1=s2;
Fact=Fact*i;
i=i+1;
s2=(s2+1)/(float)Fact;
}
while(s2-s1>0.00005);
printf("Total=%10.5f\n",s2);
printf("Number of interation=%d",i);
getch();
}

No comments:

Post a Comment

Thank you for visit this site. You will get many programming news from here and learn programming very easily.

Popular Posts