Can you tell me where i have to put the free() function for the array "arr" in this code? I tried to put free(arr) before the last printf() but in this way my output is wrong. I'm trying also to check if the memory allocated is free.
int *boh(int *arr,int n);
int main() {
    int a,i,n;
    int *arr;
    int *b;
    int size = 6;
    arr = (int*) malloc(size* sizeof(int));
    for (i= 0; i<6; i++){
        printf("Give me a number: \n");
        scanf("%d",&a);
        
        if(i != 5){
            arr[i] = a;
        }
        else{
            n = a;
        }
    }
    b = boh(arr,n);
    for(i=0; i<5+n; i++){
        printf("%d\n",b[i]);
    }
    return 0;
}
int *boh(int *arr,int n){
    int *a;
    int i;
    int b;
    b = arr[4];
    a = (int*) realloc(arr,n*sizeof(int)+sizeof(arr));
    
    for(i=5; i<5+n; i++){
        b += b;
        arr[i] = b;
    }
    
    return arr;
}
 
     
    