Quick sort doubt

#include

int partition(int a[],int s,int e){
int p=a[e];
int i=s-1;
int j=s;
while(j<e){
if(a[j]>p){
j++;
}
else if(a[j]<=p){
i++;
swap(a[i],a[j]);
j++;
}

}
swap(a[i+1],a[e]);
return i+1;

}
void quickSort(int a[],int s,int e){
if(s<=e){
return ;
}

	int p=partition(a,s,e);
	quickSort(a,s,p-1);
	quickSort(a,p+1,e);

}
using namespace std;
int main() {
int n;
cin>>n;
int a[n];
for(int i =0; i<n;i++){
cin>>a[i];
}
quickSort(a,0,n-1);
for(int i=0;i<n;i++){
cout<<a[i];
}
return 0;
}
in this code of quick sort its giving error that swap is not definrd in this scope why??

hello deepak,

add this line before using any swap function -> becuase swap is there in std namespace of iostream file

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.