Welcome to my blog this is test

28 June 2012

write a program to add the following series: 1/1!+2/2!+3/3!+…n/n!


//Code:   
#include
#include
#include
 void main()
  {
   float i=1,j,n,sum=0,fact=1;
    clrscr();
    printf("\n Enter the value of n : ");
     scanf("%f",&n);
      do
       {
        fact=fact*i;
           j=i/fact;
         sum=sum+j;
           i=i+1;
       }
        while(i<=n);
    printf("\n The summation of the series is = %f",sum);
     getch();
  }

/*Output:
Enter the value of n : 7
The sum of the series is = 1/1!+2/2!+3/3!+…+7/7!


No comments:

Post a Comment