Segmentation fault in custom code

i have modified the code to populate a given output array
pls find the mistake:


it gives segmentation fault