C++ for beginners-bubble sort

what is wrong with this code ?
#include
using namespace std;
void swap(int a,int b)
{
int temp;
temp=a;
a=b;
b=temp;

}
int main(){
int n,a[1000];
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
}
int i,j;
for(i=0;i<n-1;i++){
for(j=0;j<n-i-1;j++){
if(a[j]>a[j+1]){
swap(a[j],a[j+1]);

        }
    }

}
for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
}
return 0;

}

Hi @a19JE0093
In the swap function you have to pass the arguments by reference.

Correct swap function :

void swap(int &a,int &b) {
int temp;
temp=a; a=b; b=temp;
}