Https://ide.codingblocks.com/s/63704

FIND UPPER AND LOWER BOUND
Find position of the last and first occurrence of a given number in a sorted array. If number not exist then print lower and upper bound as -1.

Input Format:
An integer n denoting the size of the array followed by n integers denoting array elements Followed by T testcases Each testcase contains integer x (whose positions are to be found)

Constraints:
Output Format
Lower bound position followed by upper bound position separates by space in each line

Sample Input
5
1 2 3 3 4
3
2
3
10
Sample Output
1 1
2 3
-1 -1

I’m only getting output for the first case

Hi Anushka, this is happening because as soon as you find the upper bound or lower bound of first query your function returns ans to main and it never goes to second iteration in any of the for loops.
You can correct this by putting a for loop in main() function only to calculate upper and lower bound for each query in key array and thus you shall remove the for loop in both the user defined functions.
Hope this helps :slight_smile: