User Specified Array Read and Modify
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;
}