Linear Search.
- Guaranteed to find the item you are searching for:
#include<iostream.h>
void main()
{ const int N = 10;
int Array[N] = {1,2,3,4,5,63,5,7,5,63};
int x = 63, i= 0; When I still haven’t found what I’m looking for - keep searching
while(Array[i] != x)
{ i = i+1;
}
cout << " x is at position: " << i;
}