Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Mathematics ProgramRSS Feeds

PROGRAM TO FIND ANSWER OF THE FOLLOWING SERIES. SUM=X-X3/3!+X5/5!-X7/7!+...

Posted By: Andre Allen     Category: C Programming     Views: 8956

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

Code for PROGRAM TO FIND ANSWER OF THE FOLLOWING SERIES. SUM=X-X3/3!+X5/5!-X7/7!+... 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: 



Andre Allen
Andre Allen author of PROGRAM TO FIND ANSWER OF THE FOLLOWING SERIES. SUM=X-X3/3!+X5/5!-X7/7!+... is from Houston, United States.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!