pbl1
pbl1
Sub-Data Structure
Sec-3A
Project based Learning
Online Library Management System
Objective
The Online Library Management System (OLMS) aims to streamline and
automate the management of library resources, enabling users and
administrators to access and manage books efficiently.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
char title[100];
int available;
} Book;
typedef struct {
} ReservationQueue;
typedef struct {
int top;
int history[MAX_USERS];
} BorrowHistoryStack;
Book library[MAX_BOOKS];
ReservationQueue queue;
BorrowHistoryStack stack;
int total_books = 0;
int total_users = 0;
void initQueue() {
queue.front = -1;
queue.rear = -1;
if (queue.rear == MAX_USERS - 1) {
if (queue.front == -1) {
queue.front = 0;
queue.rear++;
queue.reservations[queue.rear] = userID;
int dequeue() {
if (queue.front == -1) {
return -1;
queue.front++;
return userID;
void initStack() {
stack.top = -1;
}
void pushStack(int userID) {
if (stack.top == MAX_USERS - 1) {
} else {
stack.top++;
stack.history[stack.top] = userID;
int popStack() {
if (stack.top == -1) {
return -1;
stack.top--;
return userID;
strcpy(library[total_books].title, title);
library[total_books].available = 1;
total_books++;
void listBooks() {
printf("Available Books in the Library:\n");
if (library[i].available) {
listBooks();
int bookID;
scanf("%d", &bookID);
} else {
library[bookID - 1].available = 0;
pushStack(userID);
listBooks();
int bookID;
scanf("%d", &bookID);
} else {
library[bookID - 1].available = 1;
if (userIDForReservation != -1) {
listBooks();
int bookID;
scanf("%d", &bookID);
} else {
library[bookID - 1].available = 0;
void undo() {
if (userID == -1) {
} else {
int main() {
initQueue();
initStack();
addBook("Introduction to Algorithms");
int choice, userID;
while (1) {
printf("5. Exit\n");
scanf("%d", &choice);
switch (choice) {
case 1:
scanf("%d", &userID);
borrowBook(userID);
break;
case 2:
scanf("%d", &userID);
returnBook(userID);
break;
case 3:
scanf("%d", &userID);
reserveBook(userID);
break;
case 4:
undo();
break;
case 5:
printf("Exiting system.\n");
exit(0);
default:
return 0;
output
1. Borrow Book
2. Return Book
3. Reserve Book
5. Exit
3. Design Patterns in C
4. Introduction to Algorithms
1. Borrow Book
2. Return Book
3. Reserve Book
5. Exit
3. Design Patterns in C
1. Borrow Book
2. Return Book
3. Reserve Book
4. Undo Last Borrow Action
5. Exit
Exiting system.