Linear Search
Linear search, also known as sequential search is an algorithm for finding a target value within a list. It sequentially checks each element of the list for the target value until a match is found or until all the elements have been searched.
static int Search(int* list, int count, int data) {
for (int i = 0; i < count; i++) {
if (data == list[i]) return i;
}
return -1;
}
Example
int list[5] = { 153, 26, 364, 72, 321 };
int index = Search(list, 5, 364);
Output
index: 2