User Specified Array Read and Modify How may this code be improved upon, the user inputs array of specified length and replaces each element that is smaller than the mean of the first and last element with the mean.

Is there a better way to pass the array to the function (ref/ptr, etc.), or more efficient way to manage memory (when handling array)?

I know the vector container from STL is ideal but just wanted to gain some insight on fundamentals.

#include &lt;iostream&gt;
using namespace std;

void replaverage(int arr[], size_t n){
    cout&lt;&lt;"Enter array length"&lt;&lt;endl;
    cin&gt;&gt; n;
    for(int i=0; i&lt;n; i++){
        cout&lt;&lt;"Enter the numbers"&lt;&lt;endl;
        cin&gt;&gt;arr[i];
        cout&lt;&lt;endl;
    }
    int f=arr[0];
    int l=arr[n-1];
    double av=(f+l)/2;
    for(int j=0; j&lt;n; j++){
        if(arr[j]&lt;av){
            arr[j]=av;
        }
    }
    for (int i=0; i&lt;n; i++){
        cout&lt;&lt;arr[i]&lt;&lt; " ";}
}


int main(int argc, char* argv[]){
    size_t x=10;
    int arr[x];
    replaverage(arr,x);
    return 0;
}
Something to keep in mind is that this statement is truncating data:
        arr[j]=av;

because it is assigning a double to an int.
As was mentioned in a comment there are c++ container types that would be better than a old C style array, two of these are std::array&lt;type, arraySize&gt; and std::vector&lt;type&gt;. std::array is a fixed size and std::vector is a variable size. Both would allow the use of iterators that might simplify the code.
Avoid using namespace std;
If you are coding professionally you probably should get out of the habit of using the using namespace std; statement. The code will more clearly define where cout and other identifiers are coming from (std::cin, std::cout). As you start using namespaces in your code it is better to identify where each function comes from because there may be function name collisions from different namespaces. The identifiercout you may override within your own classes, and you may override the operator &lt;&lt; in your own classes as well. This stack overflow question discusses this in more detail.
std::endl
It is better for performance if &quot;\n&quot; is used rather than std::endl in output, std::endl flushes the output buffer as well as putting out a new line, and this can slow down loops.
Complexity
The function replaverage should really be 2 functions, one to input the data and a second to process the data. Perhaps a third to print the data.
Horizontal Spacing
It would be better if there were spaces around operators that separate operands.
#include &lt;iostream&gt;
#include &lt;vector&gt;

std::vector&lt;int&gt; getData()
{
    int n;
    std::vector&lt;int&gt; intputData;
    std::cout &lt;&lt; &quot;Enter array length\n&quot;;
    std::cin &gt;&gt; n;
    std::cout &lt;&lt; &quot;Enter the numbers\n&quot;;
    for(int i = 0; i &lt; n; i++){
        int tmpIn;
        std::cin &gt;&gt; tmpIn;
        intputData.push_back(tmpIn);
    }

    return intputData;
}

void modifyData(std::vector&lt;int&gt; &amp;data)
{
    int f=data[0];
    int l=data[data.size() - 1];
    double av = (f + l)/2;
    for (auto j: data)
    {
        if(j &lt; av){
            j = av;
        }
    }
}

void printData(std::vector&lt;int&gt; &amp;data)
{
    for (auto i: data)
    {
        std::cout &lt;&lt; i &lt;&lt; &quot; &quot;;
    }
}

int main(int argc, char* argv[]){

    std::vector&lt;int&gt; data = getData();
    modifyData(data);
    printData(data);

    return 0;
}