/* A simple example of linear search using parallel arrays of students heights and names. Query the user for a height, search for that height and report the student's name if found. */ #include #include "genlib.h" #include "simpio.h" #define Students 10 int LinearSearchForInteger(int target, int array[], int n); main() { int heights[Students] = {54, 48, 60, 61, 49, 62, 64, 63, 59, 55}; string names[Students] = {"Lisa", "John", "Steve", "Sally", "Lane", "Horace", "Hector", "Sean", "Amy", "Gary"}; int find, result; printf("Enter a height to search for> "); find = GetInteger(); result = LinearSearchForInteger(find, heights, Students); if (result != -1) printf("%s is %d inches tall.\n", names[result], find); else printf("No one in the class is %d inches tall.\n", find); } // return index of target, or -1 if not found int LinearSearchForInteger(int target, int array[], int n) { int i; for (i=0; i