// // 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 bool 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; }