// Pantea Aria // Example: creating a dynamic array with malloc // then growing it later using realloc #include #include // TODO: write a function that creates and returns // a malloced array of given size int *build_array(int size); // TODO: write a function to print an array void show_array(int array[], int size); int main(void) { int size; printf("Enter initial size: "); scanf("%d", &size); // TODO: call build_array and check for NULL int *numbers = /* TODO */; // TODO: print the original array show_array(/* TODO */); // We decide the array needs to grow int new_size = size + 1; // TODO: use a temporary pointer with realloc int *temp = /* TODO */; // TODO: check if realloc failed // if successful, update numbers // TODO: assign a value to the new element // TODO: print the resized array // TODO: free the memory return 0; }