Have you learned about linear search or binary search?
The link could help you on how to write the code.
http://www.cplusplus.com/forum/general/75624/
Pseudocode for linear search.
Set found to false.
Set position to −1.
Set index to 0.
While found is false and index < number of elements
If list[index] is equal to search value
found = true.
position = index.
End If
Add 1 to index.
End While.
Return position.
Here is the pseudocode for a function that performs a binary search on an array:
Set first index to 0.
Set last index to the last subscript in the array.
Set found to false.
Set position to −1.
While found is not true and first is less than or equal to last
Set middle to the subscript halfway between array[first]
and array[last].
If array[middle] equals the desired value
Set found to true.
Set position to middle.
Else If array[middle] is greater than the desired value
Set last to middle − 1.
Else
Set first to middle + 1.
End If.
End While.
Return position.