// Pantea Aria // malloc and array example #include #include // Function prototypes int *allocate_marks(int size); void print_marks(int marks[], int size); int main(void) { int size; printf("Enter number of marks: "); scanf("%d", &size); // TODO 1: // Call allocate_marks and store the returned pointer int *marks = NULL; // TODO 2: // Check if marks is NOT NULL // If it is valid: // - Call print_marks // - Free the allocated memory return 0; } // This function should: // - Allocate memory for 'size' integers // - Check if malloc returned NULL // - Initialise each element with some value // - Return the pointer int *allocate_marks(int size) { // TODO 3: // Allocate memory using malloc // TODO 4: // Check if memory allocation failed // If so, print "Out of memory" and return NULL // TODO 5: // Use a loop to initialise each element // Example idea: marks[i] = i * 2; // TODO 6: // Return the pointer } // This function should print all elements void print_marks(int marks[], int size) { // TODO 7: // Use a loop to print each element on a new line }