Dynamic memory allocation

why output array is dynamically allocated if it has the same size everytime

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()