From b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b Mon Sep 17 00:00:00 2001 From: priyanka Date: Wed, 24 Jun 2015 15:03:17 +0530 Subject: initial commit / add all books --- 662/CH9/EX9.9/example9_9.JPG | Bin 0 -> 22997 bytes 662/CH9/EX9.9/example9_9.sci | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100755 662/CH9/EX9.9/example9_9.JPG create mode 100755 662/CH9/EX9.9/example9_9.sci (limited to '662/CH9/EX9.9') 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 Binary files /dev/null and b/662/CH9/EX9.9/example9_9.JPG 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 -- cgit