Contact Management System Project with Report
Welcome to our website govtjobsyllabus.in In this post, we are going to add another mini C programming project which is similar to a phone book project in C so if you have read our post then this project will be very easy for you.
This project is about a contact management system project in c with a project report so let's start:
contact management system project in c
In this program, all the users can also add, delete and view all contact numbers.
contact management system source code in c
typedef struct { char name[50]; char phone[20]; char email[50]; } Contact; Contact contacts[MAX_CONTACTS]; int numContacts = 0; void addContact() { Contact newContact; printf("Enter name: "); scanf("%s", newContact.name); printf("Enter phone number: "); scanf("%s", newContact.phone); printf("Enter email: "); scanf("%s", newContact.email); if (numContacts < MAX_CONTACTS) { contacts[numContacts] = newContact; numContacts++; printf("Contact added successfully.\n"); } else { printf("Cannot add contact. Maximum limit reached.\n"); } } void displayContacts() { if (numContacts > 0) { printf("Contact List:\n"); for (int i = 0; i < numContacts; i++) { printf("Name: %s\n", contacts[i].name); printf("Phone: %s\n", contacts[i].phone); printf("Email: %s\n\n", contacts[i].email); } } else { printf("No contacts found.\n"); } } int main() { int choice; while (1) { printf("Contact Management System\n"); printf("1. Add Contact\n"); printf("2. Display Contacts\n"); printf("3. Exit\n"); printf("Enter your choice: "); scanf("%d", &choice); switch (choice) { case 1: addContact(); break; case 2: displayContacts(); break; case 3: printf("Exiting program. Goodbye!\n"); exit(0); default: printf("Invalid choice. Please try again.\n"); } } return 0; }
Explanation
- We add necessary header files like stdio.h (For input/output operations), stdlib.h (used for memory allocation and exit functions) and string.h ( string manipulation functions.)
- We define the maximum contact number in MAX_CONTACTS.
- A structure 'Contact' is also used to represent the information of a contact.
- in this structure, three fields are defined (name, phones, and email)
- Now an array 'contacts' is declared to store the contacts and a variable 'numContacts' helps to track the number of contacts stored.
Functions
- displayContacts() function used to show the list of contacts.
Choices :
Remember loop will continue until you exit the program.
No comments:
Post a Comment