Question #24573

Write a C program to find the sum of the series 1+ 1/2! +1/3! + 1/4! +..............+ 1/n!

Expert's answer

#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;

}

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;

}

## Comments

Assignment Expert22.02.13, 09:37You're welcome. We are glad to be helpful.

If you really liked our service please press like-button beside answer field. Thank you!

Ladarva22.02.13, 09:29Thank u vry mch.....it works!!!!!!!!!!!!!!

## Leave a comment