Write a C program to find the sum of the series 1+ 1/2! +1/3! + 1/4! +..............+ 1/n!
#include <stdio.h>
int main()
{
printf("Enter n:\n");
unsigned n=0;
do
{
scanf( "%d", &n);
}
while ( n==0 );
double fact=1;
double sum=0;
int i;
for ( i=1; i<=n; ++i )
{
fact=fact/i;
sum=sum+fact;
}
printf( "Sum=%f\n", sum);
return 0;
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
Adobe Flash