Skip to main content
Search
Search This Blog
Livecodo
Pages
Home
Courses
Blog
About us
More…
Share
Get link
Facebook
X
Pinterest
Email
Other Apps
March 28, 2024
Write a C program to calculate the following Sum: Sum=1-x^2/2! +x^4/4!-x^6/6!+x^8/8!-x^10/10!.
#include
#include
main() { int counter,f_coun; float sum=0,x,power,fact; printf("\tEQUATION SERIES : 1- X^2/2! + X^4/4! - X^6/6! + X^8/8! - X^10/10!"); printf("\n\tENTER VALUE OF X : "); scanf("%f",&x); for(counter=0, power=0; power<=10; counter++,power=power+2) { fact=1; for(f_coun=power; f_coun>=1; f_coun--) fact *= f_coun; sum=sum+(pow(-1,counter)*(pow(x,power)/fact)); } printf("SUM : %f",sum); }
Popular Posts
March 26, 2024
Dynamic Memory allocation in C
May 18, 2024
Searching and sorting Algorithm in C