Tuesday, July 28, 2009

Find the sum of first 10 term of exponential series.use do-while loop & --operator.?

write a programe in 'C'.

Find the sum of first 10 term of exponential series.use do-while loop %26amp; --operator.?
Above answer is ok except for not using the -- operator:


Need to start at 10 and to decrement i use the statement:





i--;





This changes the problem somewhat. Another problem in the first answer is that fact is not initialized, so it will always equal zero resulting in a division by zero error.
Reply:i could not understand operator --. any way iam giving u the program.please make clear about that operator.


i hope u know the exponential formula.


1+x+(x*x)/2!+(x*x*x)/3!+......





main(){


int x,fact,i;


float sum;


printf("enter x value:");


scanf("%d",%26amp;x);


sum=1;


i=1


do


{sum+=(x)/(fact);


x*=x;


i++;


fact=fact*i;


}while(i%26lt;=10);


printf("%f",sum);


}


No comments:

Post a Comment