diff options
author | priyanka | 2015-06-24 15:03:17 +0530 |
---|---|---|
committer | priyanka | 2015-06-24 15:03:17 +0530 |
commit | b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch) | |
tree | ab291cffc65280e58ac82470ba63fbcca7805165 /662/CH9/EX9.9 | |
download | Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2 Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip |
initial commit / add all books
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 |