diff options
Diffstat (limited to '659/CH9/EX9.8/exm9_8.sci')
-rwxr-xr-x | 659/CH9/EX9.8/exm9_8.sci | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/659/CH9/EX9.8/exm9_8.sci b/659/CH9/EX9.8/exm9_8.sci new file mode 100755 index 000000000..813fafff3 --- /dev/null +++ b/659/CH9/EX9.8/exm9_8.sci @@ -0,0 +1,21 @@ +// Example 9.8
+//Write a multifunction to illustrate the properties of global variables.
+funcprot(0);
+function[x]=fun1()
+ global x;
+ x=x+10; //global x
+endfunction
+function[x]=fun2()
+ x=1 //Local x
+endfunction
+function[x]=fun3()
+ global x;
+ x=x+10; //global x
+endfunction
+ global x;
+ x=10;
+ printf("x=%d\n",x)
+ //calling fun1(),fun2(),fun3() functions
+ printf("x=%d\n",fun1());
+ printf("x=%d\n",fun2());
+ printf("x=%d\n",fun3());
|