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!) + .....
- #include<stdio.h>
- main()
- {
- float result, temp_calc, num, temp, factorial;
- result=0;
- for (num=1; num<=7; num++)
- {
- for (temp=1, factorial=1; temp<=num; temp++)
- {
- factorial = factorial*temp;
- temp_calc = (num/factorial);
- }
- result=result+temp_calc;
- }
- printf("(1/1!) + (2/2!) + (3/3!) + (4/4!) + (5/5!) + (6/6!) + (7/7!) = %f", result);
- }
Learn More :
For Loop
Series
Upto N terms
Factorial
Add
- C Program To Add Digits Of Entered Number
- C Program To Add n Numbers
- C Program to Adds literal to list of literals
- C Program to Add-Subtract Series 5-10+15
- C Program to Add Series 1+3+5
- C program that lets the user choose if he wants to add a item to the shopping list or print it out
- C Program that prompts the user to input a string, (whitespaces allowed)
- C Program to : add/sub/multi/divi works
- Adding two polynomial functions C Program Using Structure
- Program to Add Two Polynomials Using Linked List C Program