Code:

#include <iostream>
using namespace std;

void sort(int ar[], int size)
{
    int temp;
    for(int i = 0; i < size; i++)
        for(int j = 0; j < size - i - 1; j++)
            if(ar[j] > ar[j + 1])
            {
                temp = ar[j];
                ar[j] = ar[j + 1];
                ar[j + 1] = temp;
            }
}

int main()
{
    int *array;
    int size;
    cout << "Enter size of array: ";
    cin >> size;
    array = new int[size];
    for (int x = 0; x < size; x++)
    {
        cout << "Enter value for index " << x + 1 << ": ";
        cin >> array[x];
    }
    cout << "Before sorting: ";
    for (int i = 0; i < size; i++)
    {
        if (i == (size - 1))
            cout << array[i];
        else
            cout << array[i] << ", ";
    }
    sort(array, size);
    cout << "\nAfter sorting: ";
    for (int j = 0; j < size; j++)
    {
        if (j == (size - 1))
            cout << array[j];
        else
            cout << array[j] << ", ";
    }
    cin.ignore();
    cin.get();
    delete array;
    return 0;
}