Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 17

BLDEA’S V.P. Dr. P.G.

HALAKATTI COLLEGE OF
ENGINEERING AND TECHNOLOGY
VIJAYAPUR – 586103

DEPARTMENT OF INFORMATION SCIENCE &


ENGINEERING
A PROJECT REPORT ON
“DESIGN AND IMPLEMENTATION OF A
PHONE BOOK APPLICATION USING LINKED LIST
IN C ”
Submitted in partial fulfillment of the requirement
for the award of the degree of

BACHELOR OF ENGINEERING
IN
INFORMATION SCIENCE & ENGINEERING

UNDER THE GUIDENCE OF


Dr.P.H.Unki
SUBMITTED BY
ANUSHA DARPHAL 2BL22IS007
DIKSHA R G 2BL22IS016
PRIYANKA JADAV 2BL22IS028
SUPRITA KARADI 2BL22IS057
1. Structure Definition:
 struct PhoneBookEntry: Represents a phone book entry with fields for
name, phone number, and a pointer to the next entry in the linked list.
2. Functions:
 createEntry : Allocates memory for a new phone book entry and
initializes its fields.
 addEntry: Adds a new entry to the phone book by creating a new entry
and inserting it at the beginning of the linked list.
 deleteEntry : Deletes an entry from the phone book based on the
provided name.
 modifyEntry: Modifies the phone number of an existing entry based on
the provided name.
 displayEntries: Displays all entries in the phone book by traversing the
linked list.
 freePhoneBook : Frees the memory allocated for the entire phone book
linked list.
3. Main Function:
 main: Implements the user interface for interacting with the phone
book. It includes a menu with options to add, delete, modify, display
entries, and exit the program. The user's choice determines the action
taken.
4. Usage:
 The program runs in a loop until the user chooses to exit (option 5).
 The user can add entries by providing a name and phone number.
 Entries can be deleted based on the provided name.
 Phone numbers of existing entries can be modified.
 The user can display all entries in the phone book.
 The program dynamically allocates memory for each entry and ensures
proper memory deallocation when exiting.
5. Note:
 The program uses dynamic memory allocation (malloc) to create new
entries, and memory is freed when entries are deleted or when the
program exits.

This program provides a basic example of managing a phone book using a linked list
in C. However, it lacks error handling and input validation, which would be important
considerations for a production-level application.
The objectives of this phone book application program include:

1. Data Organization:
 Utilize a linked list data structure to organize and store phone book
entries.
 Each entry consists of a name, phone number, and a pointer to the next
entry in the linked list.
2. User Interaction:
 Provide a user-friendly interface through the console, allowing users to
interact with the phone book application.
 Display a menu with options for adding, deleting, modifying phone
numbers, displaying entries, and exiting the program.
3. Entry Manipulation:
 Allow users to add new phone book entries by providing a name and
phone number.
 Provide the capability to delete entries based on the provided name.
 Allow users to modify the phone number of an existing entry.
4. Display Functionality:
 Implement a function to display all entries in the phone book,
providing users with an overview of the stored information.
5. Memory Management:
 Dynamically allocate memory for each phone book entry to
accommodate a variable number of entries.
 Properly free allocated memory when entries are deleted or when the
program exits to prevent memory leaks.
6. Error Handling:
 Provide appropriate feedback to the user if an entry is not found during
deletion or modification.
 Handle invalid user input by displaying error messages and prompting
the user to enter valid information.
7. User Experience:
 Offer a simple and intuitive user experience, allowing users to perform
common phone book operations easily.
8. Graceful Exit:
 Allow users to exit the program in a controlled manner, freeing all
allocated memory before terminating.
9. Documentation and Output:
 Include informative output messages to guide the user through each
operation.
 Display the phone book entries in a readable format for user
convenience.
Overall, the program aims to create a functional and interactive phone book
application that allows users to manage, view, and modify their contacts efficiently.

The phone book application uses a linked list data structure to manage phone book
entries. Below is an explanation of the methodology used for each function in the
program:

1. Structure Definition:
 struct PhoneBookEntry: Defines the structure of a phone book entry with
fields for name, phone number, and a pointer to the next entry in the
linked list.
2. createEntry Function:
 Objective: Allocate memory for a new phone book entry and initialize
its fields.
 Methodology:
 Uses malloc to dynamically allocate memory for a new
PhoneBookEntry structure.
 Copies the provided name and phone number into the newly
created entry.
 Sets the next pointer to NULL.
 Returns the pointer to the newly created entry.
3. addEntry Function:
 Objective: Add a new entry to the phone book.
 Methodology:
 Calls the createEntry function to create a new entry with the
provided name and phone number.
 Inserts the new entry at the beginning of the linked list by
updating the next pointer of the new entry to point to the
current head of the list.
 Updates the head of the list to point to the new entry.
4. deleteEntry Function:
 Objective: Delete an entry from the phone book.
 Methodology:
 Traverses the linked list to find the entry with the specified
name.
 If the entry is not found, prints an error message and returns.
 If the entry is found, adjusts the pointers to skip the entry in the
linked list.
 Frees the memory allocated for the deleted entry.
5. modifyEntry Function:
 Objective: Modify the phone number of an existing entry.
 Methodology:
 Traverses the linked list to find the entry with the specified
name.
 If the entry is not found, prints an error message and returns.
 If the entry is found, updates the phone number field with the
provided new phone number.
6. displayEntries Function:
 Objective: Display all entries in the phone book.
 Methodology:
 Traverses the linked list and prints the name and phone number
of each entry.
 Displays a message if the phone book is empty.
7. freePhoneBook Function:
 Objective: Free the memory allocated for the entire phone book.
 Methodology:
 Traverses the linked list, freeing the memory for each entry.
 Uses two pointers ( current and next) to ensure proper traversal
and deallocation.
8. main Function:
 Objective: Implement the user interface and control flow for the phone
book application.
 Methodology:
 Uses a do-while loop to display a menu of options and prompt
the user for their choice.
 Calls the appropriate function based on the user's choice.
 Continues until the user chooses to exit.

Overall, the methodology involves creating, modifying, and deleting phone book
entries using a linked list, ensuring proper memory management throughout the
program. The user interacts with the application through a menu-driven interface.
INTRODUCTION
The provided program is a simple console-based phone book application implemented in C.
It allows users to manage a phone book by performing operations such as adding new
entries, deleting entries, modifying phone numbers, and displaying the existing entries. The
application employs a linked list data structure to organize and store phone book entries,
providing a dynamic and flexible approach for managing contacts.

Usage Instructions:

1. Users are prompted with a menu offering options to add, delete, modify,
display entries, or exit the program.
2. For adding an entry, users input a name and phone number.
3. To delete an entry, users specify the name of the entry to be removed.
4. Modifying an entry involves providing the name of the entry to be modified
and the new phone number.
5. Displaying entries shows a list of all current contacts in the phone book.
6. The program allows users to exit gracefully, freeing allocated memory.

Educational Value:

This program serves as an educational example of implementing basic data


structures (linked lists) in C for managing a simple application like a phone book. It
demonstrates concepts such as dynamic memory allocation, user input handling, and
basic linked list operations. The code is well-structured, making it a useful resource
for those learning or teaching introductory programming concepts in C.

While the program successfully implements a basic phone book


application, there are considerations for further enhancement, such as
implementing more advanced features, improving error handling, and
refining the user interface for a more polished user experience.

Key Findings and Contributions of the Phone Book Application:

1. Linked List Implementation:


 The program utilizes a linked list data structure to store phone
book entries. Each entry contains a name, phone number, and a
pointer to the next entry.
2. Dynamic Memory Allocation:
 Memory is dynamically allocated for each phone book entry
using the malloc function. This allows for flexibility in managing a
variable number of entries.
3. Addition of Entries:
 The program provides the functionality to add new entries to
the phone book. The addEntry function inserts new entries at the
beginning of the linked list, ensuring efficient insertion.
4. Deletion of Entries:
 Users can delete entries based on the provided name using the
deleteEntry function. The program handles edge cases such as
deleting the head of the linked list or entries in the middle.
5. Modification of Phone Numbers:
 The modifyEntry function allows users to update the phone
number of an existing entry by providing the entry's name and
the new phone number.
6. Displaying Entries:
 The displayEntries function prints all entries in the phone book,
providing users with a clear overview of the stored information.
7. User Interface:
 The main function implements a user-friendly menu-driven
interface. Users can easily interact with the program by
choosing options to add, delete, modify, display entries, or exit
the application.
8. Graceful Exit and Memory Deallocation:
 The program ensures proper memory deallocation before
exiting. The freePhoneBook function is responsible for freeing the
memory allocated for the entire phone book, preventing
memory leaks.
9. Input Validation:
 The program incorporates basic input validation by checking
for invalid menu choices and notifying the user to enter a valid
option.
10.Error Handling:
 Error messages are displayed when attempting to perform
operations on non-existing entries (e.g., deletion or
modification of an entry that is not in the phone book).
11.Structured Code:
 The code is well-structured, with modular functions that
perform specific tasks. This makes the program easy to read,
understand, and maintain.
12.Educational Value:
 The program serves as an educational example of a linked list-
based phone book application in C, demonstrating
fundamental concepts such as dynamic memory allocation,
linked lists, and user interaction.

Background of the Project:


The provided C program implements a simple phone book application
using a linked list data structure. Let's discuss the background and potential
context of this project:

1. Educational Purpose:
 This project is likely created for educational purposes,
especially for students learning C programming and data
structures. It serves as a hands-on example for practicing
concepts such as structures, linked lists, dynamic memory
allocation, and user input handling.
2. Fundamental Data Structures:
 The use of a linked list for storing phone book entries
demonstrates a fundamental data structure. Linked lists offer
flexibility in managing dynamically changing data, making them
suitable for scenarios where the number of entries can vary.
3. Introduction to Dynamic Memory Allocation:
 The project introduces the concept of dynamic memory
allocation using the malloc function to create new phone book
entries. This is a crucial aspect of managing memory efficiently
in C programs.
4. Basic User Interaction:
 The program provides a simple command-line interface with a
menu-driven system. Users can interact with the phone book
by adding, deleting, modifying entries, and displaying the
current list.
5. CRUD Operations:
 The application covers basic CRUD (Create, Read, Update,
Delete) operations commonly found in database and
information management systems. Users can create, view,
update, and delete phone book entries.
6. Error Handling and User Guidance:
 The program includes basic error handling to notify users when
an operation fails, such as attempting to delete or modify an
entry that does not exist. User-friendly prompts guide the user
through the menu options.
7. Memory Management:
 The inclusion of a function to free allocated memory
(freePhoneBook) demonstrates good programming practice by
preventing memory leaks.
8. Structured Programming:
 The code is well-structured, using functions for specific tasks,
enhancing readability, and facilitating code maintenance.
9. Project Expansion:
 This project can serve as a foundation for further expansion and
enhancement. Additional features, such as searching for entries,
sorting, or saving/loading data from a file, could be
implemented to make the phone book more sophisticated.
10.Potential Real-World Application:
 While this project is a basic example, similar principles can be
applied to real-world applications, such as contact
management systems or small-scale databases.

Overall, this phone book application project provides a practical example


for learning and applying core concepts of C programming and data
structures in a meaningful context.

Motivation for Choosing this Project:


1. Hands-on Application of Data Structures:
 Developing a phone book application allows for the practical
implementation of data structures, specifically linked lists. It provides a
real-world context for understanding how linked lists can be used to
manage and organize information.
2. Dynamic Memory Allocation:
 The project involves dynamic memory allocation, a fundamental
concept in C programming. Learning how to allocate and deallocate
memory is essential for writing efficient and error-free programs.
3. User Input Handling:
 The project includes user interaction through a menu-driven interface.
Handling user input, making decisions based on that input, and
providing feedback are crucial skills in programming.
4. CRUD Operations:
 Implementing Create, Read, Update, and Delete (CRUD) operations is
common in many applications. This project covers the basics of
managing and manipulating data, which is a fundamental skill for a
programmer.
5. Error Handling:
 The program incorporates error handling by checking for the existence
of entries before deletion or modification. This helps in creating more
robust and user-friendly applications.
6. Practical Application of File Operations:
 Although not present in the current implementation, this project can be
expanded to include file operations for saving and loading phone book
data. This would introduce file handling concepts, enabling the storage
of data between program executions.
7. Structured Programming:
 The code structure, with functions for different tasks, adheres to the
principles of structured programming. This promotes code readability,
modularity, and easier maintenance.
8. Introduction to Software Development:
 Developing a small-scale application like a phone book serves as a
gentle introduction to software development. It allows for a step-by-
step approach in building a functional program.
9. Personal Utility:
 A phone book application is a tool that people can relate to and find
useful in their daily lives. This can increase personal motivation and
engagement in the project.
10. Foundation for Further Learning:
 The skills acquired and concepts learned in this project can serve as a
solid foundation for more complex programming tasks and projects. It
lays the groundwork for understanding larger software systems.

In summary, choosing a phone book application as a project provides a balance


between practical application, foundational learning, and the potential for expansion
into more advanced topics. The motivation likely lies in creating a meaningful and
accessible program while mastering essential programming concepts
INTRODUCTION
The provided program is a simple console-based phone book application implemented in C.
It allows users to manage a phone book by performing operations such as adding new
entries, deleting entries, modifying phone numbers, and displaying the existing entries. The
application employs a linked list data structure to organize and store phone book entries,
providing a dynamic and flexible approach for managing contacts.

Usage Instructions:

7. Users are prompted with a menu offering options to add, delete, modify,
display entries, or exit the program.
8. For adding an entry, users input a name and phone number.
9. To delete an entry, users specify the name of the entry to be removed.
10. Modifying an entry involves providing the name of the entry to be modified
and the new phone number.
11. Displaying entries shows a list of all current contacts in the phone book.
12. The program allows users to exit gracefully, freeing allocated memory.

Educational Value:

This program serves as an educational example of implementing basic data


structures (linked lists) in C for managing a simple application like a phone book. It
demonstrates concepts such as dynamic memory allocation, user input handling, and
basic linked list operations. The code is well-structured, making it a useful resource
for those learning or teaching introductory programming concepts in C.

You might also like