#include<iostream>
using namespace std;
int main()
{
int ele[20],temp,i,j;
int no_of_ele;
cout<<"\n --------------------------------";
cout<<"\n Sorting. ";
cout<<"\n --------------------------------";
cout<<"\n How many elements you want to store : ";
cin>>no_of_ele;
cout<<"\n Enter the Elements...\n\t";
for(i=0;i<no_of_ele;i++)
{
cin>>ele[i];
}
for(i=0;i<no_of_ele;i++)
{
for(j=i+1;j<no_of_ele;j++)
{
if(ele[i]>ele[j])
{
temp=ele[i];
ele[i]=ele[j];
ele[j]=temp;
}
}
}
cout<<"\n --Ascending Order...\n\t";
for(i=0;i<no_of_ele;i++)
{
cout<<ele[i]<<" ";
}
cout<<"\n\n --Descending Order...\n\t";
for(i=no_of_ele-1;i>=0;i--)
{
cout<<ele[i]<<" ";
}
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: