summaryrefslogtreecommitdiff
path: root/662/CH9/EX9.9
diff options
context:
space:
mode:
authorpriyanka2015-06-24 15:03:17 +0530
committerpriyanka2015-06-24 15:03:17 +0530
commitb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch)
treeab291cffc65280e58ac82470ba63fbcca7805165 /662/CH9/EX9.9
downloadScilab-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-x662/CH9/EX9.9/example9_9.JPGbin0 -> 22997 bytes
-rwxr-xr-x662/CH9/EX9.9/example9_9.sci27
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
new file mode 100755
index 000000000..c86689010
--- /dev/null
+++ b/662/CH9/EX9.9/example9_9.JPG
Binary files differ
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