diff options
Diffstat (limited to '662/CH9/EX9.9')
-rwxr-xr-x | 662/CH9/EX9.9/example9_9.JPG | bin | 0 -> 22997 bytes | |||
-rwxr-xr-x | 662/CH9/EX9.9/example9_9.sci | 27 |
2 files changed, 27 insertions, 0 deletions
diff --git a/662/CH9/EX9.9/example9_9.JPG b/662/CH9/EX9.9/example9_9.JPG Binary files differnew file mode 100755 index 000000000..c86689010 --- /dev/null +++ b/662/CH9/EX9.9/example9_9.JPG diff --git a/662/CH9/EX9.9/example9_9.sci b/662/CH9/EX9.9/example9_9.sci new file mode 100755 index 000000000..e82e4efc1 --- /dev/null +++ b/662/CH9/EX9.9/example9_9.sci @@ -0,0 +1,27 @@ + //programming Example 9.9
+//calculate the average of n numbers,
+ //then compute the deviation of each number aboutthe average.
+
+n = 5;
+List={3, -2, 12, 4.4, 3.5};
+
+function[] = main()
+ Sum = 0;
+
+ //calculate and display the average
+ for count = 1:1:n
+ Sum=Sum+List(count);
+ end
+ avg = Sum/n;
+ printf("\nThe average is %5.2f\n\n", avg);
+
+ //Calculate and display the deviations about the average
+ for count = 1:1:n
+ d = List(count)-avg;
+ printf("i = %d X = %5.2f d = %5.2f\n", count, List(count), d);
+ end
+endfunction
+
+//calling main()
+funcprot(0);
+main();
\ No newline at end of file |