I didn't use return part in the recursive part and it still works

This is my function for storing all the occurrences.
int storeocc(int *a, int i, int j, int n, int *out, int key){

if(i==n){
    return j;
}
if(a[i]==key){
    out[j]=i;
    j++;
}
storeocc(a, i+1, j, n, out, key);// here i didn't right return

}

However, in the video, it has a return part there. I want to ask whether it is necessary or not to write the return part.

hello @amanb25

your function return type is int so ur function must return integer to calling function and thats why return is mandatory.

try again , ur compiler should show error like function not returning anything.

I do not get any error.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.