Wednesday, 25 May 2016

Sorted Array By Bubble Sort Method In Dev C++


Sorted Array By Bubble Sort Method In Dev C++









Code Is Given Blow Click On Read More.......:)






#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int a[5],b;
for(int i=0; i<=4; i++)
{
cout<<"Enter The Value a["<<i<<"] =";
cin>>a[i];
}
cout<<"Orignal values of Array"<<endl;
for(int i=0; i<=4; i++)
{
cout<<a[i]<<"\t";
}
for(int i=0; i<=4; i++)
{
for(int j=0; j<4; j++)
{
if(a[j+1]<a[j])
{
b=a[j+1];
a[j+1]=a[j];
a[j]=b;

}
}
}
cout<<endl<<"Sorted Array"<<endl;
for(int i=0;i<5;i++)
{
cout<<a[i]<<"\t"; 

return 0;
}

No comments: