summaryrefslogtreecommitdiff
path: root/662/CH9/EX9.8
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.8
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.8')
-rwxr-xr-x662/CH9/EX9.8/example9_8.JPGbin0 -> 31920 bytes
-rwxr-xr-x662/CH9/EX9.8/example9_8.sci33
2 files changed, 33 insertions, 0 deletions
diff --git a/662/CH9/EX9.8/example9_8.JPG b/662/CH9/EX9.8/example9_8.JPG
new file mode 100755
index 000000000..9bdfa3e60
--- /dev/null
+++ b/662/CH9/EX9.8/example9_8.JPG
Binary files differ
diff --git a/662/CH9/EX9.8/example9_8.sci b/662/CH9/EX9.8/example9_8.sci
new file mode 100755
index 000000000..94b58422d
--- /dev/null
+++ b/662/CH9/EX9.8/example9_8.sci
@@ -0,0 +1,33 @@
+ //Programming Example 9.8
+ //Deviation about an average
+
+function[] = main()
+ Sum=0;
+
+ //read a value for n
+ printf("\nHow many numbers will be averaged? ");
+ n= scanf("%d");
+ printf("\n");
+
+ //read the numbers and calculate their sum
+ for count = 1:1:n
+ printf("i = %d X = ", count);
+ //index count start from 1, so no need to denote it as (count+!) element
+ List(count) = scanf("%f");
+ Sum = Sum+List(count);
+ end
+
+ //calculate and display the average
+ avg = Sum/n;
+ printf("\n The 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