Bubble Sort code in c++ using a user defined function and bubble sort programme in c++ without using a function
void bsort(int Arr[],int n)
{
int i,j,Temp;
for(i=0;i<n-1;i++)
{
for(j=0;j<(n-1-i);j++)
if(Arr[j]>Arr[j+1])
{
Temp=Arr[j];
Arr[j]=Arr[j+1];
Arr[j+1]=Temp;
}
}
}
========================================
Bubble Sort Programme
//use header files syntax according to the compiler
#include <iostream.h>
#include<conio.h>
void main()
{
int m, i, j, temp, flag=0;
int arr[8];
cout<<"Enter Eight elements in the array";
for(i=0;i<8;i++)
cin>>arr[i];
int i,j,temp;
for(i=0;i<n-1;i++)
{
for(j=0;j<(n-1-i);j++)
if(arr[j]>arr[j+1])
{
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
cout<<"array after sorting"
for(i=0;i<8;i++)
cout<<arr[i];
//Syntax and explanation of for loop