C program to add first seven terms of the following series using a for loop: (1/1!) + (2/2!) + (3/3!) + .....

How to Write a C Program to add first seven terms of the following series using a for loop:

(1/1!) + (2/2!) + (3/3!) + .....

This C Program to add first seven terms of the following series using a for loop: (1/1!) + (2/2!) + (3/3!) + .....


  1. #include<stdio.h>
  2. main()
  3. {
  4. float result, temp_calc, num, temp, factorial;
  5. result=0;
  6. for (num=1; num<=7; num++)
  7. {
  8. for (temp=1, factorial=1; temp<=num; temp++)
  9. {
  10. factorial = factorial*temp;
  11. temp_calc = (num/factorial);
  12. }
  13. result=result+temp_calc;
  14. }
  15. printf("(1/1!) + (2/2!) + (3/3!) + (4/4!) + (5/5!) + (6/6!) + (7/7!) = %f", result);
  16. }


Learn More :