Home Uncategorized Sum of Series 1-x2/2! +x4/4!-x6/6!+x8/8!-x10/10! in C language

Sum of Series 1-x2/2! +x4/4!-x6/6!+x8/8!-x10/10! in C language

SHARE

Write a C program to calculate the following Sum: Sum=1-x2/2! +x4/4!-x6/6!+x8/8!-x10/10!.

#include<stdio.h>
int main()
{
   float x,i,t,s=1;
   printf(“Enter x value : “);
   scanf(“%f”,&x);
   t=1.0;
   for(i=2;i<=10;i+=2)
   {
      t=t*(-1)*x*x/i*(i-1);
      s=s+t;
      printf(“X = %f\n”,x);
      printf(“t = %f\n”,t);
   }
   printf(“Result = %f\n”,s);
   return 0;
}

Output:

Enter x value : 10
Result = -1296.795532

Back to the programs list.