Plz find the error in my code

#include
#include
using namespace std;
int main(){
int n ,no,i;
cin>>n;
int a[n]={0};
for (i=0; i<n ; i++){
cin>> a[i];
}
sort(a,a+n);
int non,start,end ;
cin>>non;

start = 0;
end=n-1;
while(start<=end){
	int sum ;
	sum =a[end]+a[start];

	/*while (non<a[end]){
		end--;
	
	 
     }*/
	while(sum<non){
		start++;
	}
	if (sum> non){
     	end--;}
	if (sum == non){
		cout<<a[start]<<" and "<<a[end]<< endl;
		start++;
		
	}
	


} 

}

Hello @manish.bharadwajsbh this is the correct code:
you should check till start<end and not start<=end .


Happy Learning!!

but tle is coming in this also

check this

which code you are submitting ?
in your code when sum==nos then you should do end-- as well if you are submitting your code in that it is the problem.
Happy Learning!!

im submiting code given by u

the code which i have given to you is passing all the test cases .
please try to submit it again after refreshing.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.