This program not working on every test case

If the array is -> 4, 2, 1, 3 & we have to find pair of sum 5.

There are two pairs (4, 1) & (2, 3) but the program which pratik bhaiya taught gives onlyu one pair (4,1).

Please give the current program with explanation

hello @Shivam01
array should be sorted

okky thanx a lot for helphing me out!!