why output array is dynamically allocated if it has the same size everytime
Dynamic memory allocation
this is because if you make normal array inside function then it will be destroyed after function completion and you would not be able to access the array in main() function
for that we make dynamic array and then return this array to main()