Binary search question

LINK TO CODE:
https://ide.codingblocks.com/#/s/13711
LINK TO QUESTION:
https://hack.codingblocks.com/contests/c/474/200

My doubt is that test case number 2 is giving wrong answer whereas all custom inputs given by me yield good results.

‘target’ should be compared with ‘arr[mid]’ and not with ‘mid’, and this is what you are doing in line no 14.