Computer Science, asked by Kalpanakathait, 4 months ago

Draw a flowchart to find the sum of the following series: 1/1! - 2/2! + 3/3! - 4/4! +............ up to N terms in c language​

Answers

Answered by dreamrob
2

Program :

#include<stdio.h>

#include<conio.h>

long Factorial(int n)

{

long fact = 1;

for(int i = n ; i >= 1 ; i--)

{

              fact = fact * i;

}

return fact;

}

int main()

{

int n , p = (-1);

float sum = 0.0f;

printf("Enter the value of N: ");

scanf("%d",&n);

for(int i = 1 ; i <= n ; i++)

{

             p = (-1) * p;

             sum = sum + p * ( (float)(i) / (float)(Factorial(i)) );

   }

printf("Sum of the series is : %f\n",sum);

return 0;

}

Attachments:
Similar questions