HTML & JS
#include<iostream>
using namespace std;
int main()
{
  int a[10]={12, 78,1, 10, 34};
  int n=5;
  int b=0;
  cout<<"The elements are:";
  for(int i=0;i<n;i++)
      cout<<a[i]<<" ";

  //ascending order
  for(int i=0;i<n;i++)
  {
     for(int j=i+1;j<n;j++)
         if(a[i]>a[j])
         {
             b=a[i];
             a[i]=a[j];
             a[j]=b;
         }
}
cout<<"\nSorted array in ascending order:";
for(int i=0;i<n;i++)
   cout<<a[i]<<" ";

//descending order    
  for(int i=0;i<n;i++)
  {
     for(int j=i+1;j<n;j++)
         if(a[i]<a[j])
         {
             b=a[i];
             a[i]=a[j];
             a[j]=b;
         }
  }
  cout<<"\nSorted array in descending order:";
  for(int i=0;i<n;i++)
     cout<<a[i]<<" ";
}

Generated URL:

Output:

The elements are:12 78 1 10 34 
Sorted array in ascending order:1 10 12 34 78 
Sorted array in descending order:78 34 12 10 1 
Report Bug