summaryrefslogtreecommitdiff
path: root/659/CH6/EX6.6/exm6_6.sce
diff options
context:
space:
mode:
Diffstat (limited to '659/CH6/EX6.6/exm6_6.sce')
-rwxr-xr-x659/CH6/EX6.6/exm6_6.sce24
1 files changed, 24 insertions, 0 deletions
diff --git a/659/CH6/EX6.6/exm6_6.sce b/659/CH6/EX6.6/exm6_6.sce
new file mode 100755
index 000000000..fb682a654
--- /dev/null
+++ b/659/CH6/EX6.6/exm6_6.sce
@@ -0,0 +1,24 @@
+// Example 6.6
+//Program to evaluate the series i.e.
+// 1/1-x = 1+x+x^2+x^3+.....+x^n
+
+x=input("Input value of x:"); //Read value of x
+LOOP=100; ACCURACY=0.0001; //Initialization
+sum1=0;term=1;flag=0;
+//Computation using for loop
+for n=1:LOOP
+ sum1=sum1+term;
+ if(term<=ACCURACY) then //Test for accuracy
+ flag=1;
+ break;
+ end
+ term=term*x;
+
+end
+//Print the results
+if(flag==1) then
+ printf(" EXIT FROM LOOP\n");
+ printf(" Sum =%f ; No. of terms =%d",sum1,n);
+else
+ disp("FINAL VALUE OF N IS NOT SUFFICIENT TO ACHIEVE DESIRED ACCURCY");
+end \ No newline at end of file