#include<iostream>
using namespace std;
void quick(int arr[],int first,int last)
{
    if(first<last)
    {
        int i=first;
        int j=last;
        int pivote=first;
        int temp=0;
        while(i<j)
            {
                if(arr[i]<arr[pivote] && i<j)
                {
                    i++;
                }
                else if (arr[j]>arr[pivote])
                {
                    j--;
                }
                else
                {
                    swap(arr[i],arr[j]);
                }
            }
              swap(arr[j],arr[pivote]);
              quick(arr,0,j-1);
              quick(arr,j+1,last);
    }
    
}
int main()
{
    int arr[5]={2,56,78,23,12};
    int n=5;
    quick(arr,0,n-1);
    for(int i=0;i<n;i++)
        {
            cout<<arr[i]<<endl;
        }

    cout<<arr[0]<<endl;
    cout<<arr[n-1]<<endl;
    return 0;
}

Embed on website

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