C Exercises: Calculate the sum of the series [ 1-X^2/2!+X^4/4!- .........]
18. Sum of Series [1 - X²/2! + X⁴/4! - …]
Write a program in C to find the sum of the series [ 1-X^2/2!+X^4/4!- .........].
This C program calculates the sum of a series where the terms alternate between positive and negative, involving powers of X and factorial denominators: 1-X^2/2!+X^4/4!-.. . The program will take an input value for X and a specified number of terms, then compute the sum of the series using a loop to iterate through each term, applying the appropriate sign and factorial calculation.
Sample Solution:
C Code:
Flowchart:
or
Output:
Input the Value of x :2 Input the number of terms : 5 the sum = -0.415873 Number of terms = 5 value of x = 2.000000
Flowchart:

For more Practice: Solve these Related Problems:
- Write a C program to compute the alternating series for cosine of x using a do-while loop.
- Write a C program to calculate the series 1 - x²/2! + x⁴/4! - … using recursion for factorial computation.
- Write a C program to display each term of the series and then compute the overall sum.
- Write a C program to compute the series sum and compare the result with the cos(x) function from math.h.
C Programming Code Editor:
Previous: Write a program in C to make such a pattern like a pyramid with a number which will repeat the number in the same row.
Next: Write a program in C to display the n terms of harmonic series and their sum.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.