/*WAP TO ADD 1st SEVEN TERMS OF THE FOLLOWING SERIES: (1/1!)+(2/2!)+.......+(7/7!) [using FOR loop]*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
float fact;
float sum=0;
clrscr();
printf("\nGiven series -->\n\t\t");
printf("1/1! + 2/2! + 3/3! + 4/4! + 5/5 + 6/6! + 7/7!");
for(i=1;i<=7;i++)
{
fact=1;
for(j=1;j<=i;j++)
{
fact=fact*j;
}
sum=sum+i/fact;
}
printf("\n\n\nSum of the 1st seven terms of the given series= %f",sum);
getch();
}
No comments:
Post a Comment