C++ Program to input any ten numbers and print them in ascending order Using Bubble Sorting Technique(Array Sorting)
#include<iostream.h>
#include<conio.h>
main()
{
int number[10],a,b,c,d;
clrscr(); // clear the screen
cout<<"Enter the elements of the array"<<endl;
for(int i=0;i<10;i++)
{
cout<<"Enter number for cell "<<i<<endl;
cin>>number[i];
}
cout<<endl<<"Thank You ! The data entry is over"<<endl;
cout<<"Press any key to continue";
getch();
cout<<"\a\a";
clrscr();
// sorting of data
for(int j=0;j<10;j++)
{
for(int k=0;k<9;k++)
{
if (number[k]>number[k+1])
{
a=number[k];
number[k]=number[k+1];
number[k+1]=a;
}
}
}
cout<<"The list in ascending order is ";
cout<<endl;
for(i=0;i<10;i++)
cout<<number[i]<<"\t";
cout<<endl<<"Press any key to return to the editor";
getch();
return 0;
}
Related Posts : C++ Programs
0 comments:
Post a Comment