#include(stdio.h) // place this '<' & '>' instead of '(' & ')' before stdio.h
#include(math.h)
int main(void)
{
int ct, ft;
float sum=0, x, power, fact;
clrscr();
printf("--------PROGRAM FOR SUM OF EQ. SERIES------");
printf("\n\nEnter the value of X : ");
scanf( "%f", &x);
ct=0;
for(power=0; power<=10; power=power+2)
{
fact=1; for(ft=power; ft>=1; ft--)
fact =fact* ft;
sum=sum+(pow(-1,ct)*(pow(x,power)/fact)); //EQ. FOR SUM SERIES
ct++;
}
printf("\n Sum : %f",sum);
getch();
return 0;
}
Explanation:-
Here 'ct' means count .
And variable 'ft' & 'fact' are used to find factorial based 'power' value.
No comments:
Post a Comment