Challenge 1: Allocating, Filling, Printing, and Freeing an int Array — Possible Solution ==================================================================== #include #include int main() { int *nums = malloc(5 * sizeof(int)); if (nums == NULL) { return 1; // allocation failed } for (int i = 0; i < 5; i++) { nums[i] = i + 1; } for (int i = 0; i < 5; i++) { printf("%d\n", nums[i]); } free(nums); return 0; } Output: 1 2 3 4 5 WHY THIS WORKS AS AN ANSWER ------------------------------ The NULL check happens immediately after malloc, before the memory is ever used -- per the chapter, malloc's failure return must always be checked, not assumed away. The array is filled and printed while nums is still a valid pointer, and free(nums) is the last thing that happens, only after every use of the memory is complete.