Advertisement Remove all ads

Write a Program to Calculate Summation of Series 1/1! + 2/2! + 3/3! +….+ N/N! - Structured Programming Approach

Write a program to calculate summation of series
1/1! + 2/2! + 3/3! +….+ n/n!

Advertisement Remove all ads

Solution

#include <stdio.h>
#include <conio.h>
double sumseries(double m)
{
double sum2 = 0, f = 1, i;
    for (i = 1; i <= m; i++)
{
        f = f * i;
        sum2 = sum2 +(i / f);
}
return(sum2);
}
double sumseries(double);
main()
{
    double number,sum;
    clrscr();
    printf("\n Enter the value: ");
    scanf("%lf", &number);
    sum = sumseries(number);
    printf("\n Sum of the above series = %lf ", sum);
}

 

Output:
Enter the value: 4
Sum of the above series = 2.666667
Concept: Array
  Is there an error in this question or solution?
Advertisement Remove all ads
Advertisement Remove all ads
Advertisement Remove all ads
Share
Notifications

View all notifications


      Forgot password?
View in app×