Bubble Sorting in ascending order c++

#include<iostream.h>
#include<conio.h>
int main()
{

int a[30];
int i,n,j,temp;
cout<<"\n\t\t\t   ^_^ Bubble SorTinG ^_^ \n\n";
cout<<"\n-> Enter The RanGe Of ArrAy --> ";
cin>>n;

for(i=1;i<=n;i++)
{
    cout<<"\n\t\t Enter The "<<i<<" NumBer : ";
    cin>>a[i];
}
for(i=1;i<=n;i++)
{
for(j=1;j<=n-1;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
cout<<"\n\n\n\t^_^ SorTeD ArrAy In AscEnDinG OrdeR :\n";
cout<<"\n\n";
for(i=1;i<=n;i++)
{
    cout<< "\n\t\t NumBer : ";
cout<<a[i]<<"\n";
}
getch ();
}
SHARE

Milan Tomic

Hi. I’m Designer of Blog Magic. I’m CEO/Founder of ThemeXpose. I’m Creative Art Director, Web Designer, UI/UX Designer, Interaction Designer, Industrial Designer, Web Developer, Business Enthusiast, StartUp Enthusiast, Speaker, Writer and Photographer. Inspired to make things looks better.

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment