Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write the following function: int *create_array(int n, int initial_value); The f

ID: 3614772 • Letter: W

Question

Write the following function: int *create_array(int n, int initial_value); The function should return a pointer to a dynamicallyallocated int array withn members, each of which is initializedto initial_value. The return value shouldbe NULL if the array can't beallocated. Write the following function: int *create_array(int n, int initial_value); The function should return a pointer to a dynamicallyallocated int array withn members, each of which is initializedto initial_value. The return value shouldbe NULL if the array can't beallocated.

Explanation / Answer

[ memset is a much cleaner way to set the values of the array.] I must object to this. memset() will cast the value to unsignedchar, so information loss occurs. Feel free to verify it. If there would've been a standard equivalent that didn't do that, Iwould have used it.