O'Reilly logo

Absolute Beginner's Guide to Programming, Second Edition by Greg Perry

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Searching Arrays

There are many methods for searching arrays for a specific value. Suppose you have several arrays with inventory data. The first array, PartNo(), holds all your inventory item part numbers. The second array, Desc(), holds the description of each of those parts. The third array, Price(), contains the price of each corresponding part. You might keep all the inventory data on the disk and then read that data into the arrays when it is time to work with the data.

An inventory program often needs a lookup routine. A user could type a part number, and the computer program would search the PartNo() array for a match. When it finds one, for example at subscript 246, you could then print the 246th element in the Desc() and Price() arrays, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required