• + 1 comment

    in the code there are two steps to acquire a new array filled with zeroes:

    1. At first step the allocation itself: int *a=(int )malloc(sizeof(int)(n+1));
    2. Second step is to propagate zero values using for-loop upon newly created array.

    In my opinion, we can do the same with single call of "calloc". It supposed to be faster in theory, cause calloc is hardware dependent and probably we don't have to loop over N items again just for get them zero valued, since calloc could know is it actually required or not, so on some harware it could be already zeroes or hardware knows better how to zero during allocation faster