Find the closest number

Ln:2 Col:1 Lines:2
C     C++      
OUTPUT WINDOW

Find the closest number

Given an array of sorted integers and find the closest value to the given number. Array may contain duplicate values and negative numbers.

Example : Array : 2,5,6,7,8,8,9
Target number : 5
Output : 5

Target number : 11
Output : 9

Target Number : 4
Output : 5

Please use the following function signature:

C/C++ : void solution(int *array, int arraysize, int number);

© Preply 2012. All rights reserved.