#include <iostream>
using namespace std;
class sorting
{
int a[5]={19,-67,25,-45,40},b,i,j;
public:
void calc();
void display();
};
void sorting ::calc()
{
for(i=0;i<=5;i++)
{
for(j=i+1;j<5;j++)
{
if(a[i]>a[j])
{
b=a[i];
a[i]=a[j];
a[j]=b;
}
}
}
}
void sorting ::display()
{
cout<<"ASCENDING ORDER"<<endl;
cout<<"_______________"<<endl;
for(i=0;i<5;i++)
cout<<endl<<a[i]<<endl;
cout<<"DESCENDING ORDER"<<endl;
cout<<"________________"<<endl;
for(i=5-1;i>=0;i--)
cout<<endl<<a[i]<<endl;
}
int main()
{
cout<<"SORTING AN ELEMENTS"<<endl;
sorting a;
a.calc();
a.display();
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: