Search This Blog

Friday, October 7, 2011

For values of x=0.1,0.2,0.3,0.4 and 0.5, it is required to find the sum of the series given below till the individual term of the series become less than 0.0001. Write a program to evaluate the sum and display the results x + x2/2! + x3/3! + ...... x2=x*x and so on

#include<conio.h>
#include<stdio.h>
#include<math.h>
void main()
{
int k;
float sum,x,power,fact=1,term;
clrscr();
x=0.1;
while(x<=0.5)
{
k=1;
sum=0.0;
do
{
power=pow(x,k);
fact=fact*k;
term=power/fact;
sum+=term;
k++;
}while(term>0.0001);
printf("x=%.2f sum = %f\n",x,sum);
x=x+0.1;
}
getch();
}

No comments:

Post a Comment