diff options
Diffstat (limited to '659/CH6/EX6.5')
-rwxr-xr-x | 659/CH6/EX6.5/exm6_5.sce | 18 | ||||
-rwxr-xr-x | 659/CH6/EX6.5/exm6_5_output.PNG | bin | 0 -> 13157 bytes |
2 files changed, 18 insertions, 0 deletions
diff --git a/659/CH6/EX6.5/exm6_5.sce b/659/CH6/EX6.5/exm6_5.sce new file mode 100755 index 000000000..34071374e --- /dev/null +++ b/659/CH6/EX6.5/exm6_5.sce @@ -0,0 +1,18 @@ +// Example 6.5
+//Program illustrate use of the break statement
+
+disp("This program computes the avarage of set of numbers");
+disp("Enter values and enter a NEGATIVE value at the end");
+sum1=0;
+for m=1:1000
+ x=scanf("%f"); //Read data
+ if(x<0) then
+ break; //EXIT FROM LOOP
+ end
+ sum1=sum1+x; //Computes sum
+end
+average=sum1/(m-1); //Computes Average
+//Print the results
+printf("Number of values =%d\n",m-1);
+printf("sum1=%f\n",sum1);
+printf("Avarage =%f\n",average);
\ No newline at end of file diff --git a/659/CH6/EX6.5/exm6_5_output.PNG b/659/CH6/EX6.5/exm6_5_output.PNG Binary files differnew file mode 100755 index 000000000..178eeea75 --- /dev/null +++ b/659/CH6/EX6.5/exm6_5_output.PNG |