0
10kviews
Write a program to calculate summation of series. 1-x2/2!+x4/4!-x6/6!+x8/8!........upto n terms

Mumbai University> FE > Sem 2> STRUCTURED PROGRAMMING APPROACH

Marks: 10 M

Year: May 2016

1 Answer
2
1.2kviews

enter image description here

Program:

#include<stdio.h>
#include<conio.h>
main()
{
int i,n,fact=1,sign= -1;
float x,sum=0.0,result;
printf(“Enter Value of n:”);
scanf(“%d”,&n);
printf(“Enter Value of x:”);
scanf(“%f”,&x);

for(i=2;i<(2*n);i=i+2)
{
fact=fact*i*(i-1);
sum=sum+(sign*(pow(x,i))/fact));
sign=sign*(-1);
}
result=1+sum;
prinf(“The value of series is %f”,result);
getch();
}

Output:
Enter Value of n: 4
Enter Value of x: 0.2
The value of series is 0.980066
Please log in to add an answer.