Array target sum triplets

my code is written below and I am not able to find the error.

#include
using namespace std;
int main()
{
int n;
cin>>n;
int i,j,k,x,a[n],t;
for(i=0;i<n;i++)
{
cin>>a[i];
}
cin>>x;
for(i=0;i<n;i++)
{
for(j=0;j<n-i;j++)
{
if(a[j]>a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
for(k=j+1;k<n;k++)
{
if(a[i]+a[j]+a[k]==x)
{
cout<<a[i]<<", β€œ<<a[j]<<” and "<<a[k]<<endl;
}
}
}
}
}

@Shivam31 hey shivam bhati there is small modification required i.e you don’t need to do this step
for(i=0;i<n;i++)
{
for(j=0;j<n-i;j++)
{
if(a[j]>a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
}
instead apply a inbuilt sort function on the array.
and one more thing is that do modify your loop as
i=0 to n-2
j=i+1 to n-1
k=j+1 to n

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.

can you plz help me, no test case pass not even a single

#include
#include
using namespace std;

bool sumpairs(int a[],int n,int target)
{
for(int i=0;i<n-2;i++)
{
for(int j=i+1;j<n-1;j++)
{
for(int k=j+1;k<n;k++)
{
if(a[i]+a[j]+a[k]==target)
{
cout<<a[i]<<" β€œ<<a[j]<<” and β€œ<<a[k]<<”\n";
}
}
}
}
return 0;
}
int main()
{
int a[1000];
int n,target;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
sort(a,a+n);
cin>>target;
sumpairs(a,n,target);
}