CODE:
#include
using namespace std;
void bubblesort(int a[],int n){
for(int i=0;i<n;++i)
{ cout<<endl;
for(int j=0;j<n-i;++j)
{
if(a[j]>a[j+1])
swap(a[j],a[j+1]);
}
for(int i=0;i<5;++i)
cout<<a[i]<<" “;
}
}
int main()
{
int a[5]={637,937,64,20,748};
bubblesort(a,5);
for(int i=0;i<5;++i)
cout<<a[i]<<” ";
return 0;
}
PROBLEM ENCOUNTERED: The value 937 is getting converted to 0.
NOTE: I used cout in the function to see what was happening at every step.