Algorithm
Algorithm
Define the maximum number of books, maximum length of book title, and maximum
length of author name using #define.
Define a structure named "Book" that contains four elements:
a. title - character array of length MAX_TITLE_LEN to store the title of the book.
b. author - character array of length MAX_AUTHOR_LEN to store the name of the
author.
c. id - integer to store the unique ID of the book.
d. num_copies - integer to store the number of copies of the book.
Define another structure named "Library" that contains two elements:
a. books - an array of Book structures of length MAX_BOOKS to store all the books
in the library.
b. num_books - integer to store the current number of books in the library.
Define a function named "display_books" that takes a Library structure as an
argument and displays all the books in the library along with their details.
Define a function named "add_book" that takes a pointer to a Library structure as
an argument and adds a new book to the library.
a. Check if the library is full.
b. If not, get the title, author name, ID, and number of copies of the new book
from the user.
c. Add the new book to the books array of the library.
d. Increment the num_books variable of the library.
Define a function named "remove_book" that takes a pointer to a Library structure
and an ID of the book to be removed as arguments and removes the book from the
library.
a. Find the index of the book in the books array of the library using its ID.
b. If the book is found, remove it by shifting all the elements in the array after
it one position to the left.
c. Decrement the num_books variable of the library.
In the main function, create a new Library structure with num_books initialized to
0.
Define a loop that displays a menu of options for the user to choose from.
Get the user's choice from the menu.
Depending on the user's choice, call the appropriate function.
If the user chooses to quit, exit the program.