bsc

Comprehensive codebase and cou...
Log | Files | Refs | Activity | README | LICENSE

root / semester_1 / letusc / lucproblem009.c

lucproblem009.c (427B)


      1 /* Write a program to add first seven terms of the following series using a
      2 for loop.
      3     1 / 1! + 2 / 2! + 3 / 3! + ...
      4 */
      5 /* Let Us C, Chap - 6, Page - 102, Problem 6.2 */
      6 
      7 #include <stdio.h>
      8 #define N 7 // update N here
      9 
     10 int main()
     11 {
     12     double sum = 0; int fact = 1;
     13     for (int i = 1; i <= N; i++)
     14     {
     15         fact *= i;
     16         sum += (double)i / fact;
     17     }
     18     printf("Sum of the series : %g", sum);
     19     return 0;
     20 }
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror