Sunday, 16 October 2011

Bubble Sorting In Ascending Order


/*****************************************************************************************************************************/
// This Program Bubble Sort An Integer Array In Ascending Order.
/*****************************************************************************************************************************/
#include<iostream>

using namespace std;

int main()
{
int array[7]={10,3,2,6,14,8,5};
int len=7;
int temp;
 for(int i=1;i<len-1;i++)
{
for(int j=0;j<len;j++)
{
if(array[j]>array[j+1] && (j+1)<len)// then swap
{
temp=array[j];
array[j]=array[j+1];
array[j+1]=temp;
}
}

}

cout<<"Array After Bubble Sorting is(ascending order):"<<endl;
for(int k=0;k<len;k++)
cout<<array[k]<<" ";
return 0;
}www.google.com

1 comment:

  1. For Further Assistance ,Your can mail me at rida.ameerr@gmail.com

    ReplyDelete