clanguage07@gmail.com

clanguage07@gmail.com

Saturday, June 16, 2012

write a c program to find sum of following series? sum=1-X2/2!+.............

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
   int x,i,j,sign=-1;
   long int fact=1;
   double s=0.00;
   clrscr();
   printf("enter the value of x:\t");
   scanf("%d",&x);
   for(i=0;i<=10;i=i+2)
   {
   fact=1;
   for(j=1;j<=i;j++)
   {
   fact=fact*j;
   }
   s=s+((-1*sign)*pow(x,i))/fact;
   if(sign==-1)
       sign=1;
       else
         sign=-1;
         }
printf("\n the result is:%1f",s);
getch();
}

No comments:

Post a Comment

GET MORE INFORMATION

http://ads.qadservice.com/t?id=c2168e05-8974-4816-872a-91936ff7379d&size=1024x768&drct=true