Saturday 11 December 2010

Algorithm for To calculate the sum. Sum=1-x2/2!+ x4/4!- x6/6!+ x8/8!- x10/10!

Objective:4


To calculate the sum. Sum=1-x2/2!+ x4/4!- x6/6!+ x8/8!- x10/10!

Algorithm:

main program:

Step 1: start
Step 2: declare x,i,n,s=0,c
Step 3: read x value
Step 4: for i=0 , n=0; i<=10; i=i+2, n++ goto step 5
Step 5: s=s+(pow(-1,n)*pow(x,i)/fact(i))
Step 6: print s value
Step 7: stop

Sub program:


Step 1: while x!=0 goto Step 2
Step 2: y=y+x; x—
Step 3: return y
Step 4: return to main program



No comments:

Post a Comment