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.8 | |
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.8')
-rwxr-xr-x | 662/CH9/EX9.8/example9_8.JPG | bin | 0 -> 31920 bytes | |||
-rwxr-xr-x | 662/CH9/EX9.8/example9_8.sci | 33 |
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 Binary files differnew file mode 100755 index 000000000..9bdfa3e60 --- /dev/null +++ b/662/CH9/EX9.8/example9_8.JPG 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 |