Target sum pairs

I am getting output as 0 and 5.
where as in my array there is not 0.

MY CODE

#include
#include
using namespace std;
int compare(int a,int b){
return a<b;
}
void targetsum(int *arr,int n,int target){
sort(arr,arr+n,compare);

int left=0;
int right=n-1;

while(left<right){
	int sum=arr[left] + arr[right];
	if (sum>target)
	{
		right--;
	}
	else if(sum<target){
		left++;
	}
	else{
		cout<<arr[left]<<"and"<<arr[right]<<endl;
		right--;
		left++;

	}
}

}
int main()
{
int arr[100];

int target;

cin>>target;

int n=sizeof(arr)/sizeof(arr[0]);

for (int i = 0; i < n;i++)
{
    cin>>arr[i];
}
targetsum(arr,n,target);

return 0;

}

Take the size of of array as input which is n you are just taking size as 100 by doing that calculation int n=sizeof(arr)/sizeof(arr[0]);

okay that is correct but in problem i cant take input as n.

In problem. It is written that 1 st line will be size of array and next n line will be of array elements and then target element…