
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

Parallel arrays int itemNumber[10] [0] 1234 [1] 6529 [2] 9983 [3] 4567 [4] 2020 [5] 9987 [6] 1212 [7] 3948 [8] 0098 [9] 8876 double price[10] [0] 386. [1] 0. [2] 12. [3] 99. [4] 99. [5] 23. [6] 0. [7] 386. [8] 8. [9] 0. Suppose we want to find the price of item 2020. Given the function: int search( int theArray[ ], int arrSize, int target ) /* search theArray (of size arrSize) for the first occurrence of target. Return the index if it is there. Return - 1 if it does not occur in theArray */ We can use it: int location; location = search(itemNumber, 10, 2020); if (location != - 1) printf ("It costs $%0.2lf.\n", price[location]); else printf("We do not have that item..\n");