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.12 | |
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.12')
-rwxr-xr-x | 662/CH9/EX9.12/example9_12.JPG | bin | 0 -> 32070 bytes | |||
-rwxr-xr-x | 662/CH9/EX9.12/example9_12.sci | 37 |
2 files changed, 37 insertions, 0 deletions
diff --git a/662/CH9/EX9.12/example9_12.JPG b/662/CH9/EX9.12/example9_12.JPG Binary files differnew file mode 100755 index 000000000..2f0a5c717 --- /dev/null +++ b/662/CH9/EX9.12/example9_12.JPG diff --git a/662/CH9/EX9.12/example9_12.sci b/662/CH9/EX9.12/example9_12.sci new file mode 100755 index 000000000..20698b3a0 --- /dev/null +++ b/662/CH9/EX9.12/example9_12.sci @@ -0,0 +1,37 @@ + //Programming Example 9.12
+ //passing a variable along with an array to the function
+
+a = 1; //global variable
+
+function[] = main()
+ b = 2; //local variable
+ printf("\nFrom main, before calling the function: \n");
+ printf("a = %d b = %d\n", a, b);
+ for count = 1:3
+ c(count) = 10*(count+1);
+ printf("c[%d] = %d\n", count, c(count));
+ end
+
+ c=modify(b,c);
+ printf("\n From main, after calling the function: \n ");
+ printf("a = %d b = %d\n", a, b);
+ for count =1:3
+ printf("c[%d] = %d\n", count, c(count));
+ end
+endfunction
+
+function[c] = modify(b,c) //function definition
+ printf("\n From the function, after modifying the values: \n");
+ a=-999;
+ b=-999;
+ printf("a = %d b = %d\n", a, b);
+ for count =1:3
+ c(count)=-9;
+ printf("c[%d] = %d\n", count, c(count));
+ end
+ return c;
+endfunction
+
+//calling main()
+funcprot(0);
+main();
\ No newline at end of file |