//
// Example 10.8. Function to search an unordered array sequentially
// Pre: a is a char array with n elements.
// x is a char.
// Post: The index of the first occurrence of x in a has been
// returned or, if not found, -1.
//
int SeqSearchUnordered(const char a[], int n, char x)
{
int i = 0, // index
found = FALSE; // indicates if x has been found
while (i < n && !found)
{
if (x == a[i])
found = TRUE;
else
i++;
}
if (!found)
i = -1;
return i;
}