#include<iostream>
using namespace std;
int main()
{
    int a[50],n,i,j,temp,k=1;
    cout<<"\n SORTING NUMBERS "<<endl;
    cout<<"\n Enter the no of elements in an array : ";
    cin>>n;
    cout<<n<<endl;
    for(i=0;i<n;i++)
    {
        cout<<"\nEnter the element "<<k<<" :" ;
        cin>>a[i];
        cout<<a[i];
        k++;
    }
    cout<<"\n\n";
    for(i=0;i<n;i++)
    {
        cout<<a[i]<<",";
    }
    cout<<endl;
    
    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;
            }   
        }
    }
    cout<<"\n ASCENDING ORDER : "<<endl<<"\n\t";
    for(i=0;i<n;i++)
    {
        cout<<a[i]<<"  ";
    }     
    cout<<"\n\n DESCENDING ORDER :"<<endl<<"\n\t";
    for(i=n-1;i>=0;i--)
    {
        cout<<a[i]<<"  ";
    } 
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: