Search:

Submit Article

# PROGRAM TO FIND ANSWER OF THE FOLLOWING SERIES. INPUT STEPS FROM KEYBOARD. SUM=X-X3/3!+X5/5!-X7/7!+...(TAKE VALUE OF X ALSO).

Posted By: Jacob Bouchard     Category: C Programming     Views: 5329

## Code for PROGRAM TO FIND ANSWER OF THE FOLLOWING SERIES. INPUT STEPS FROM KEYBOARD. SUM=X-X3/3!+X5/5!-X7/7!+...(TAKE VALUE OF X ALSO). in C Programming

#include<stdio.h>
#include<conio.h>
void main()
{
longint x,i,j,k,n,sq,cnt;
double fact,sum=0;
clrscr();
printf("\n ENTER THE VALUE OF N: ");
scanf("%ld",&n);
printf("\n ENTER THE VALUE OF X: ");
scanf("%ld",&x);
for(i=1,cnt=1;i<=n;i=i+2,cnt++)
{
for(j=1,sq=1;j<=i;j++)
sq=sq*x;
printf("\n SQ = %ld",sq);
for(k=1,fact=1;k<=i;k++)
fact=fact*k;
printf("\n fact = %7.2lf",fact);

if(cnt%2==1)
sum=sum+(sq/fact);
else
sum=sum-(sq/fact);
printf("\n THE SUM OF THIS SERIES IS %7.2lf\n",sum);
}
getch();

}

/*
****************************** OUTPUT *********************************

ENTER THE VALUE OF N: 5

ENTER THE VALUE OF X: 2

SQ = 2
fact = 1.00
THE SUM OF THIS SERIES IS 2.00

SQ = 8
fact = 6.00
THE SUM OF THIS SERIES IS 0.67

SQ = 32
fact = 120.00
THE SUM OF THIS SERIES IS 0.93

*/
Share:

 Jacob Bouchard author of PROGRAM TO FIND ANSWER OF THE FOLLOWING SERIES. INPUT STEPS FROM KEYBOARD. SUM=X-X3/3!+X5/5!-X7/7!+...(TAKE VALUE OF X ALSO). is from Montreal, Canada. View All Articles

 Please enter your CommentComment should be atleast 30 Characters.Please put code inside [Code] your code [/Code]. No Comment Found, Be the First to post comment!