0% found this document useful (0 votes)
97 views

Lab Project Report Template - CSE

The document describes a phone book management system project implemented by a student. The system allows users to store, retrieve, update, and delete phone records through a command-line interface. It utilizes file handling to persistently store phone records. The student encountered challenges like input validation, data integrity, and error handling during development. The phone book management system offers a practical way to organize contact information for personal, business, and organizational use.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views

Lab Project Report Template - CSE

The document describes a phone book management system project implemented by a student. The system allows users to store, retrieve, update, and delete phone records through a command-line interface. It utilizes file handling to persistently store phone records. The student encountered challenges like input validation, data integrity, and error handling during development. The phone book management system offers a practical way to organize contact information for personal, business, and organizational use.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Green University of Bangladesh

Department of Computer Science and Engineering (CSE)


Faculty of Sciences and Engineering
Semester: (Spring, Year:2021), B.Sc. in CSE (Day/Eve)

Course Title: Dat Structure


Course Code: 106 Section:DD-PC

Lab Project Name: Telephone book management system

Student Details

Name ID
1. Sadikul Islam Adil 222902003
2.

Submission Date : 6/11/2023


Course Teacher’s Name : Farhana Akter Sunny

[For Teachers use only: Don’t Write Anything inside this box]

Lab Project Status

Marks: ………………………………… Signature: .....................

Comments: .............................................. Date: ..............................


Introduction

Introduction :

In today's digital era, the management of phone records is crucial for efficient
organization and retrieval of data. The Phone Management System offers a convenient way
to store and manage phone records using a simple and user-friendly interface. It allows users
to perform common operations on the phone records, enabling efficient data manipulation
and retrieval.

Objective:
a) Efficient Data Management: The system aims to provide an organized and efficient way to
manage phone-related information. It allows users to store, retrieve, update, and delete phone
records effortlessly.

b) User-Friendly Interface: The system is designed with a user-friendly interface to ensure


ease of use. It provides intuitive menu options and clear instructions, making it convenient
for users to navigate and perform desired operations.

c) Data Security: The system focuses on maintaining the security of phone records. It ensures
that only authorized users can access and modify the data. It also provides options for data
backup and restoration to prevent data loss.

d) Fast and Accurate Searching: The system facilitates quick and accurate searching of
phone records based on various parameters like phone model, brand, price range, etc. This
helps users to find specific information efficiently.

c) Robust Error Handling: The system incorporates robust error handling mechanisms to
handle unexpected inputs and errors gracefully. It provides informative error messages to
guide users in case of any issues or invalid inputs
Implementation of the Project
phonebook management system :

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_NAME_LENGTH 50
#define MAX_PHONE_LENGTH 20

// Structure to represent a contact


typedef struct {
char name[MAX_NAME_LENGTH];
char phone[MAX_PHONE_LENGTH];
} Contact;

// Structure to represent the phone book


typedef struct {
Contact *contacts;
int size;
int capacity;
} PhoneBook;

// Function prototypes

PhoneBook* createPhoneBook(int capacity);


void destroyPhoneBook(PhoneBook *phoneBook);
void addContact(PhoneBook *phoneBook, const char *name, const char *phone);
void deleteContact(PhoneBook *phoneBook, const char *name);
void searchContact(PhoneBook *phoneBook, const char *name);
void sortPhoneBook(PhoneBook *phoneBook);
void printPhoneBook(PhoneBook *phoneBook);

int main()
{
PhoneBook *phoneBook = createPhoneBook(10);
int choice;
char name[MAX_NAME_LENGTH], phone[MAX_PHONE_LENGTH];

do {
printf("Phone Book Application\n");
printf("1. Add contact\n");
printf("2. Delete contact\n");
printf("3. Search contact\n");
printf("4. Sort phone book\n");
printf("5. Print phone book\n");
printf("0. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);

switch (choice)
{
case 1:
printf("Enter name: ");
scanf("%s", name);
printf("Enter phone number: ");
scanf("%s", phone);
addContact(phoneBook, name, phone);
break;
case 2:
printf("Enter name to delete: ");
scanf("%s", name);
deleteContact(phoneBook, name);
break;
case 3:
printf("Enter name to search: ");
scanf("%s", name);
searchContact(phoneBook, name);
break;
case 4:
sortPhoneBook(phoneBook);
printf("Phone book sorted successfully.\n");
break;
case 5:
printPhoneBook(phoneBook);
break;
case 0:
break;
default:
printf("Invalid choice. Please try again.\n");
break;
}

printf("\n");
} while (choice != 0);
destroyPhoneBook(phoneBook);

return 0;

// Create a phone book with the specified capacity


PhoneBook* createPhoneBook(int capacity) {
PhoneBook *phoneBook = (PhoneBook*)malloc(sizeof(PhoneBook));
phoneBook->contacts = (Contact*)malloc(capacity * sizeof(Contact));
phoneBook->size = 0;
phoneBook->capacity = capacity;
return phoneBook;
}

// Destroy the phone book and free memory


void destroyPhoneBook(PhoneBook *phoneBook) {
free(phoneBook->contacts);
free(phoneBook);
}

// Add a new contact to the phone book


void addContact(PhoneBook *phoneBook, const char *name, const char *phone) {
if (phoneBook->size >= phoneBook->capacity) {
printf("Phone book is full. Cannot add more contacts.\n");
return;
}

Contact newContact;
strcpy(newContact.name, name);
strcpy(newContact.phone, phone);

phoneBook->contacts[phoneBook->size] = newContact;
phoneBook->size++;

printf("Contact added successfully.\n");


}

// Delete a contact from the phone book


void deleteContact(PhoneBook *phoneBook, const char *name) {
int found = 0;
for (int i = 0; i < phoneBook->size; i++) {
if (strcmp(phoneBook->contacts[i].name, name) == 0) {
found = 1;
for (int j = i; j < phoneBook->size - 1; j++) {
phoneBook->contacts[j] = phoneBook->contacts[j + 1];
}

phoneBook->size--;
printf("Contact deleted successfully.\n");
break;
}
}

if (!found) {
printf("Contact not found.\n");
}
}

// Search for a contact in the phone book


void searchContact(PhoneBook *phoneBook, const char *name) {
int found = 0;
for (int i = 0; i < phoneBook->size; i++) {
if (strcmp(phoneBook->contacts[i].name, name) == 0) {
found = 1;
printf("Name: %s, Phone: %s\n", phoneBook->contacts[i].name,
phoneBook->contacts[i].phone);
break;
}
}

if (!found) {
printf("Contact not found.\n");
}
}

// Sort the phone book by name using bubble sort


void sortPhoneBook(PhoneBook *phoneBook) {
for (int i = 0; i < phoneBook->size - 1; i++) {
for (int j = 0; j < phoneBook->size - i - 1; j++) {
if (strcmp(phoneBook->contacts[j].name, phoneBook->contacts[j + 1].name) >
0) {
Contact temp = phoneBook->contacts[j];
phoneBook->contacts[j] = phoneBook->contacts[j + 1];
phoneBook->contacts[j + 1] = temp;

// Print all contacts in the phone book


void printPhoneBook(PhoneBook *phoneBook) {
if (phoneBook->size == 0) {
printf("Phone book is empty.\n");
return;
}

printf("Phone Book:\n");
for (int i = 0; i < phoneBook->size; i++) {
printf("Name: %s, Phone: %s\n", phoneBook->contacts[i].name,
phoneBook->contacts[i].phone);
}
}
Performance Evaluation

Simulation Environment:
Results and Discussions:

a) Data Storage:
The system utilizes file handling techniques to store phone records persistently. It creates a file
(e.g., "phones.dat") to store the data in a structured format. Each phone record is stored as a
separate entry in the file, making it easy to retrieve and manipulate the data.

b) User Interface:
The system employs a command-line interface to interact with the users. It presents interface,
where users can select specific options by entering corresponding numbers. The system validates
user inputs and guides users through the available operations using descriptive messages.

c) Implementation Challenges:
During the development of the Phone Management System, a few challenges were encountered,
including:
Input Validation: Ensuring the validation and handling of user inputs to prevent errors or
unexpected behavior.
Data Integrity: Implementing mechanisms to maintain data integrity and consistency during
operations like adding, updating, and deleting records.
Error Handling: Incorporating robust error handling techniques to gracefully handle exceptions and
provide meaningful error messages to the users.
Performance Optimization: Optimizing the system's performance to handle a large number of
phone records efficiently
Analysis and Outcome:
Conclusion

Introduction:

The phone book management system is a practical application that can be used in
various domains, such as personal contact management, business directories, and
organizational phone directories. It offers a convenient way to store and retrieve
contact information, making it easier to manage and access essential contacts.

Practical Implications:

Personal Contact Management: Individuals can use this system to maintain their
personal contacts, including friends, family members, colleagues, and other
important contacts. They can add, delete, and search for contacts based on their
names or phone numbers.

Business Directories: Companies and organizations can utilize this system to create
and manage their internal phone directories. It enables employees to quickly find
and contact colleagues or departments within the organization.

Organizational Phone Directories: Educational institutions, government offices,


and other large organizations can implement this system to maintain
comprehensive phone directories. It facilitates easy access to contact information
for students, faculty members, staff, and other stakeholders.
Scope of Future Work:

The implemented phone book management system provides a solid foundation, but
there are several areas where future work can expand and enhance its capabilities:

1. User Interface Improvement: The current implementation uses a simple


text-based menu interface. Enhancing the user interface by developing a
graphical user interface (GUI) could provide a more user-friendly experience.
2. Additional Functionality: Additional features can be incorporated into the
system, such as the ability to update contact details, categorize contacts into
groups or categories, import/export contacts from/to external files, and
implement search filters based on various criteria.
3. Performance Optimization: As the size of the phone book grows, the efficiency
of various operations, such as search and sort, could be improved. Implementing
advanced algorithms and data structures, such as binary search or balanced
trees, can enhance the system's performance.
4. Data Persistence: Currently, the phone book is stored only in memory and is lost
once the program terminates. Adding data persistence capabilities by integrating
a database or file storage system would enable users to save and retrieve
contacts across multiple program sessions.Security Enhancements:
Incorporating security measures, such as password protection, encryption of
contact information, and access control, would ensure the privacy and integrity
of sensitive contact details.
5. The phone book management system is a practical application that can be used
in various domains, such as personal contact management, business directories,
and organizational phone directories. It offers a convenient way to store and
retrieve contact information, making it easier to manage and access essential
contacts.
References:

1."Data Structures and Algorithms in C" by Michael T. Goodrich, Roberto Tamassia,


and David M. Mount.

2. "Mastering Algorithms with C" by Kyle Loudon.

3. "Data Structures Using C" by Reema Thareja.

4. "C Programming Absolute Beginner's Guide" by Greg Perry and Dean Miller.

5. "Data Structures and Algorithms Made Easy in C" by Narasimha Karumanchi.

6. "Introduction to Algorithms" by Thomas H. Cormen, Charles E. Leiserson, Ronald


L. Rivest, and Clifford Stein.

7. GeeksforGeeks website - https://www.geeksforgeeks.org/

8. Tutorialspoint website - https://www.tutorialspoint.com/

9. Programiz website - https://www.programiz.com/

10. Codecademy website - https://www.codecademy.com/

You might also like