// Pantea Aria // Dynamically allocate a struct and return a pointer // Complete the TODO sections below #include #include struct book { int id; int pages; }; // Function prototypes struct book *create_book(int id, int pages); void print_book(struct book *b); int main(void) { // TODO 1: // Create a book with id 101 and 250 pages struct book *b1 = NULL; // TODO 2: // Print the book details // TODO 3: // Create another book with id 202 and 300 pages struct book *b2 = NULL; // TODO 4: // Print the second book // TODO 5: // Free both allocated books before program ends return 0; } // This function should: // - Allocate memory for a struct book // - Check if malloc returned NULL // - Initialise the fields // - Return the pointer struct book *create_book(int id, int pages) { // TODO 6: // Allocate memory using malloc // TODO 7: // Check if allocation failed // If NULL, print "Out of memory" and exit // TODO 8: // Set the struct fields using -> // TODO 9: // Return the pointer } // This function should print book details // Format: Book ID: __, Pages: __ void print_book(struct book *b) { // TODO 10: // Print the struct fields using -> }