#include void main(void) { // an array to store a list of scores float fScore[12], // the array is searched for this score fLookup; // used as an index to step through the array int iIndex, // the index of the last score stored in the array iMax; // read in the scores into the array printf("Enter up to 10 floats, enter 0 when done: \n"); scanf("%f", &fScore[0]); for(iIndex = 0; fScore[iIndex] != 0; iIndex = iIndex + 1) scanf("%f", &fScore[iIndex + 1]); iMax = iIndex - 1; // read a score to be searched in the array printf("What score do you want to look up? "); scanf("%f", &fLookup); // search the array for this score for(iIndex = 0; iIndex <= iMax; iIndex = iIndex + 1) if(fScore[iIndex] == fLookup) // abandon the loop if element is found break; // if it was found, then a break was executed and "iIndex" was <= "iMax" if(iIndex <= iMax) printf("The score of %.2f was number %d in the list.\n", fLookup, iIndex + 1); // otherwise, "iIndex" went past the value of "iMax". else printf("The score of %.2f was not found in the list.\n", fLookup); }