Sunday, August 7, 2011

C Program to evalute the power series


#include<conio.h>
#include<stdio.h>
#define ACCURACY 0.0001
void main()
{
int n,count;
float x,term,sum;
printf(" Enter value of x : ");
scanf("%f",&x);
n=term=sum=count=1;
while(n<=100)
{
 term=term*(x/n);
 sum=sum+term;
 count=count+1;
 if(term<ACCURACY)
 n=999;
 else
 n=n+1;
}
printf(" TERMS = %d SUM = %f\n",count,sum);
getch();
}

No comments:

Post a Comment