in reply to Search an array for a pair of matching elements

This sounds a little like a homework question which tend to be frowned upon here.

Can you explain the logic behind this search (it's application in the real world etc). Also posting any work you've already attempted would be helpful. You're much more likely to get replies here if you say "I've tried X, Y and Z but can't understand why it doesn't work" rather than "do this for me".

All I'd say in the mean time is read up on for loops which should put you on (one of the) right track to solving your question.

--- Jay

All code is untested unless otherwise stated.