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 /1034/CH7/EX7.8/7s9.sce | |
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 '1034/CH7/EX7.8/7s9.sce')
-rwxr-xr-x | 1034/CH7/EX7.8/7s9.sce | 27 |
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)
|