summaryrefslogtreecommitdiff
path: root/662/CH7/EX7.8/ex7_8.sci
diff options
context:
space:
mode:
Diffstat (limited to '662/CH7/EX7.8/ex7_8.sci')
-rwxr-xr-x662/CH7/EX7.8/ex7_8.sci23
1 files changed, 23 insertions, 0 deletions
diff --git a/662/CH7/EX7.8/ex7_8.sci b/662/CH7/EX7.8/ex7_8.sci
new file mode 100755
index 000000000..3e9058dba
--- /dev/null
+++ b/662/CH7/EX7.8/ex7_8.sci
@@ -0,0 +1,23 @@
+ //Example 7.8
+//convert a lowercase character to uppercase using a programmer defined function
+funcprot(0);
+
+function[c2] = lower_to_upper (c1) //function definition
+//as conditional (?:) operater is not present in scilab, so we need to use if-else instead.
+ if (ascii(c1) >= ascii('a')) &(ascii(c1) <= ascii('z')) then
+ c2=ascii(ascii('A')+ascii(c1)- ascii('a'));
+ else
+ c2=c1;
+ end
+ return c2;
+endfunction
+
+function[] = main()
+ printf("Please enter a lowercase character: ");
+ lower= scanf("%c");
+ upper= lower_to_upper (lower); //function call
+ printf("\n The uppercase equivalent is %c\n\n",upper);
+endfunction
+
+//calling main function.
+main(); \ No newline at end of file