u

Friday 14 September 2012

C++ Program to input any ten numbers and print them in ascending order

C++ Program to input any ten numbers and print them in ascending order

 #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();
clrscr();
// sorting of data
for(int j=0;j<9;j++)
{
for(int k=j+1;k<10;k++)
{
if (number[j]>number[k])
{
a=number[j];
number[j]=number[k];
number[k]=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;
}

0 comments:

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More