See for yourself - you have announced
int podchcnt(int arr[])
those. that the podchcnt function takes an array , in other words, a pointer to its first element.
And what do you tell her in podchcnt(arr[j]) ?
Just an element ...
Here is such a discrepancy and leads to problems.
Did not go into the task, but I can assume that you want to transfer the subarray, starting with the j -th element? Then write either arr+j or &arr[j] .
And again, let me remind you that the counting of elements in an array starts from zero , so that the for (int j=1;j<=n;j++) loop for (int j=1;j<=n;j++) causes certain doubts, as well as other cycles in your full text.
Also, you have used the uninitialized variable res - it has no initial value , it can have anything, so the result can be any :) Initialize it, declaring int res = 0; .
Your recursion is unlikely to be finite - only if all arr[j] not units - since in each of its calls the same cycle will be executed, endlessly making the same calls. In this case, since you will transfer all the smaller parts of the array, there will be going beyond the bounds of the array with all the (unpleasant) consequences ...
Well, also - in this case it is not a mistake, it just doesn’t turn out quite ... I won’t even find the words. It’s not quite nice whether to pass an array as a parameter, and its size as a global variable. Pass both values as parameters - then the function will be much more universal. This is also important for recursion.