Write a C program that adds first seven terms of the following series 1/1! +2/2! + 3/3! + ..........

Posted by Tushar Bedekar


#include< stdio.h>
#include< conio.h>
int main( )
{
int n,i,j,fact;
float sum=0;
clrscr();
for(i=1; i<=7; i++) { fact=1; for(j=i; j>=1; j--)     // to find the factorial
fact=fact*j;

sum=sum+(float)i/fact;
}
printf("\nSum : %f",sum);
getch();
return 0;
}

0 comments:

Post a Comment

back to top