Its in O(n^2) but its still showing error,tell me where the error is,please

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
int a[n];
for(int i=0;i<n;i++)
{
cin >> a[i];
}
sort(a,a+n);
int s;
cout <<“Enter Pair sum value”;
cin >> s;
int currsum=0;
for(int i=0;i<n-2;i++)
{
int p=i+1;
int q=n-1;
while(p<q)
{
currsum=a[p]+a[q]+a[i];
if(currsum==s)
{
cout << a[i] <<"," <<" " << a[p]<<" " <<“and” <<" "<< a[q] << endl;
p++;
q–;
}
else if(currsum < s)
{
p++;
}
else if(currsum > s)
{
q–;
}

	}
	
}

}

Save your code on ide.codingblocks.com and then share its link.

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.