summaryrefslogtreecommitdiff
path: root/1034/CH7/EX7.8/7s9.sce
diff options
context:
space:
mode:
Diffstat (limited to '1034/CH7/EX7.8/7s9.sce')
-rwxr-xr-x1034/CH7/EX7.8/7s9.sce27
1 files changed, 27 insertions, 0 deletions
diff --git a/1034/CH7/EX7.8/7s9.sce b/1034/CH7/EX7.8/7s9.sce
new file mode 100755
index 000000000..af50bcec5
--- /dev/null
+++ b/1034/CH7/EX7.8/7s9.sce
@@ -0,0 +1,27 @@
+clear;
+clc;
+function[]=sortedsearch(a,n,ele)
+ if(a(1)>ele|a(n)<ele)
+ disp("NOT IN THE LIST");
+ else
+ i=1;
+ j=0;
+ for i=1:n
+ if(a(i)==ele)
+ printf("FOUND %d AT %d",ele,i);
+ j=1;
+ else
+ if(a(i)>ele)
+ break;
+ end
+ end
+ end
+ if(j==0)
+ disp("%d NOT FOUND",ele);
+ end
+ end
+endfunction
+//Calling Routine:
+a=[2 22 23 33 121 222 233]//a should be sorted
+disp(a,"Given array");
+sortedsearch(a,7,23)