Write  a C program to calculate the following ,where x is a fractional value.

1-x/2+x^2/4-x^3/6.

program:

#include<stdio.h>

#include<conio.h>

float x,sum=1,t=1,d;

int i,n;

clrscr();

printf("\n Input the value of x:\n");

scanf("%f",&x);

printf("Input the number of terms:\n");

scanf("%d",&n);

for(i=1;i<n;i++)

{

d=(2*i)*(2*i-1);

t=-t*x*x*/d;

sum=sum+t;

}

printf("\n the sum=%f \n Number of terms=%d\n value of x=%f\n",sum,n,x);

getch();

}


output: