0% found this document useful (0 votes)
25 views7 pages

Case Study ITPS

The document presents a case study on creating a Simple Library Management System using the C programming language, focusing on managing book records through basic concepts like structures and file handling. The project aims to facilitate book storage, issuing, and returning while ensuring data persistence. It includes implementation details, advantages, and suggestions for future improvements, making it a practical beginner-level project.

Uploaded by

tonmoyroy027
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views7 pages

Case Study ITPS

The document presents a case study on creating a Simple Library Management System using the C programming language, focusing on managing book records through basic concepts like structures and file handling. The project aims to facilitate book storage, issuing, and returning while ensuring data persistence. It includes implementation details, advantages, and suggestions for future improvements, making it a practical beginner-level project.

Uploaded by

tonmoyroy027
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Case

Study
Subject::INTRODUCTION TO PROBLEM SOLVING

Subject Code: CONT_24CSH-101

Name :Gobindo Roy Submitted TO:


UID No : 24BCS80347 Faculty Name : Mr Tushar
Branch : CSE (24INT-110 (A))

==================================================
Case Study: Simple Library Management
System in C

1. Introduction
Managing books and keeping track of which books are available, issued, or returned can be a
tiring job if done manually. So, how about making a simple Library Management System using C

programming language?

This project will show how we can use basic C concepts like structures, file handling, and
functions to create a system that stores books, issues them, returns them, and shows all
available books. It’s a great beginner-level project, perfect for understanding real-life
applications of C programming.

2. Objective
The main aim of this project is:

● To store details of books like Title, Author, Book ID, and Availability.
● To allow issuing and returning books.
● To keep records stored permanently, even after the program closes.
● To implement it neatly using modular functions.

3. Tools Used
● Language: C
● Compiler: GCC / Turbo C / Code::Blocks
● Editor: VSCode, Code::Blocks, or any text editor of your choice
4. System Design
Defining Book Structure
struct Book { int id; char title[50]; char
author[50]; int available; // 1 =
Available, 0 = Issued
};

Why structure?
Because it keeps all related information (ID, title, author, status) together, making it easy to
manage.

5. Implementation
1. Adding a New Book
void addBook()
{ struct Book b;
FILE *fp = fopen("library.dat", "ab");

printf("Enter Book ID: ");


scanf("%d", &b.id);
printf("Enter Book Title: ");
getchar(); // clears newline
fgets(b.title, 50, stdin);
printf("Enter Author Name: ");
fgets(b.author, 50, stdin);
b.available = 1;

fwrite(&b, sizeof(b), 1, fp);


fclose(fp); printf("Book added
successfully!\n");
}

2. Displaying All Books


void displayBooks()
{ struct Book b;
FILE *fp = fopen("library.dat", "rb"); printf("\

nAvailable Books:\n"); printf("ID\tTitle\t\tAuthor\t\

tStatus\n");

while (fread(&b, sizeof(b), 1, fp)) {


printf("%d\t%s\t%s\t%s", b.id, b.title, b.author,
(b.available) ? "Available\n" : "Issued\n");
}
fclose(fp);
}

3. Issuing a Book
void issueBook()
{ int id, found = 0;
struct Book b;
FILE *fp = fopen("library.dat", "rb+");

printf("Enter Book ID to issue: ");


scanf("%d", &id);

while (fread(&b, sizeof(b), 1, fp)) {


if (b.id == id && b.available == 1) {
b.available = 0; fseek(fp, -
sizeof(b), SEEK_CUR); fwrite(&b,
sizeof(b), 1, fp); printf("Book issued
successfully!\n"); found = 1; break;
}
}
if (!found) {
printf("Book not found or already issued.\n");
}
fclose(fp);
}
4. Returning a Book
void returnBook()
{ int id, found = 0;
struct Book b;
FILE *fp = fopen("library.dat", "rb+");
printf("Enter Book ID to return: ");
scanf("%d", &id);

while (fread(&b, sizeof(b), 1, fp)) {


if (b.id == id && b.available == 0) {
b.available = 1; fseek(fp, -sizeof(b),
SEEK_CUR); fwrite(&b, sizeof(b), 1,
fp); printf("Book returned
successfully!\n"); found = 1; break;
}
}
if (!found) {
printf("Book not found or not issued.\n");
}
fclose(fp);
}

6. Menu System
int main()
{ int
choice;

while (1) {
printf("\n=== Library Management System ===\
n"); printf("1. Add Book\n"); printf("2. Display
Books\n"); printf("3. Issue Book\n"); printf("4.
Return Book\n"); printf("5. Exit\n"); printf("Enter
your choice: "); scanf("%d", &choice);

switch (choice) {
case 1: addBook(); break; case
2: displayBooks(); break; case
3: issueBook(); break; case 4:
returnBook(); break; case 5:
exit(0); default: printf("Invalid
choice!\n"); }
}
return 0;
}

7. Key Concepts Used


Structures
We use a structure to store multiple attributes of a book (ID, title, author, availability) neatly in
one place.

File Handling
We use binary files (fopen, fwrite, fread, fseek) so that:

● Data remains saved permanently.


● Books' records can be updated easily.

Functions
Functions like addBook(), issueBook(), returnBook() make the program modular and easier to
manage.

8. Advantages
● No manual registers are needed.
● Easy to check book availability.
● Persistent storage using files.
● Beginner-friendly, yet practical project.
● Can be expanded further.
9. Possible Future Improvements
Here’s how you can make it better:

● Add user authentication (admin login).


● Add fine calculation for late returns.
● Store user/member records.
● Shift to dynamic memory allocation for more scalability.
● Integrate a database like SQLite.

10. Conclusion
This Library Management System shows how powerful even simple C programs can be
when used effectively. It gives hands-on experience with file handling, structures, and modular
coding—all essential for real-world projects.

11. References
1. E. Balagurusamy, "Programming in ANSI C"
A widely used textbook for learning C language, covering structures, file handling, and
functions that are used in this project.
2. Yashavant Kanetkar, "Let Us C"
Provides in-depth explanations of C programming concepts like file handling, dynamic
memory, and modular programming applied in this system.
3. Tutorialspoint - C Programming Language
https://www.tutorialspoint.com/cprogramming/index.htm
Helpful tutorials explaining structures, file handling, and pointer concepts used in the
program.
4. GeeksforGeeks - C File Handling https://www.geeksforgeeks.org/basics-file-handling-
c/
Reference for implementing file operations like fopen() , fwrite() ,
fread() , fseek() .
5. StudyTonight - C Structures https://www.studytonight.com/c/structures-in-c.php
Useful for understanding how structures are used to store multiple data types in one anti

========================================================================
========================================================================

You might also like