summaryrefslogtreecommitdiff
path: root/37/CH7/EX7.2/s2.sci
blob: 3406b80cf835eada9fd099c0aaf36677f72235c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function[]=sortedsearch(a,n,ele)
  if(a(1)&gt;ele|a(n)<ele) disp("not="" in="" the="" list");="" else="" i="1;" j="0;" for="" if(a(i)="=ele)" printf("found="" %d="" at="" %d",ele,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)
</ele)>