#include <iostream>
using namespace std;
class sort
{
public:
int a[10],i,j,temp=0,n;
void getdata()
{
cout<<"\n How many values you want to sort : ";
cin>>n;
cout<<"\n Enter the values to sort...";
for(i=0;i<n;i++)
{
cin>>a[i];
}
}
void sorting()
{
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
}
void ascending()
{
cout<<"\n Ascending Order...\n\t";
for(i=0;i<n;i++)
{
cout<<a[i]<<" ";
}
}
void decending()
{
cout<<"\n Descening Order...\n\t";
for(i=n-1;i>=0;i--)
{
cout<<a[i]<<" ";
}
}
};
int main()
{
sort obj;
cout<<"\n ---------------------------------------";
cout<<"\n Sorting. ";
cout<<"\n ---------------------------------------";
obj.getdata();
obj.sorting();
obj.ascending();
obj.decending();
cout<<"\n\n The Program was Ended...";
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: