Phonebook management system full project

In our phonebook we can save contacts, view them, edit them as well as delete them. In this phonebook management system full project we will make such system as like as our phonebook using C++. You can do the same thing like as your phonebook by this project. However, all the projects we have given here is for learning and practice purpose only. You can edit, use and practice them.

Phonebook management system full project source code

The source code for phonebook management system project is given bellow. Try to practice this in your own.

// Phonebook management system full project by C++

#include <iostream>
#include <conio.h>
#include <stdlib.h>

using namespace std;

string name[50], phoneNo[50], mobileNo[50], faxNo[50], email[50], address[50];

int counter = -1;

int validate_contact(string tmpName){
	 for(int i = 0; i <= counter; i++){
	 	if(name[i] == tmpName){
	 		return 0;
	 	}
	 }
 	 return 1;
}

void add_contact(){
     string tmpName = "";
	 cout << "Enter Name: ";
	 cin >> tmpName;

	 if(validate_contact(tmpName) == 1){
	     counter++;
	 	 name[counter] = tmpName;
	 }else{
	 	cout << endl << "Contact Already Exist with this Name" << endl;
	 	return;
	 }

     cout << "Enter Phone No: ";
     cin >> phoneNo[counter];
     cout << "Enter Mobile No: ";
     cin >> mobileNo[counter];
     cout << "Enter Fax No: ";
     cin >> faxNo[counter];
     cout << "Enter Email No: ";
     cin >> email[counter];
     cout << "Enter Address: ";
     cin >> address[counter];

}

void print_contact(int tmpCounter){
	if(name[tmpCounter] == "")
		return;
	if(counter > -1){
		cout << "Name: "<<name[tmpCounter] << endl;
		cout << "Phone No: "<<phoneNo[tmpCounter] << endl;
		cout << "Mobile No: "<<mobileNo[tmpCounter] << endl;
		cout << "Fax No: "<<faxNo[tmpCounter] << endl;
		cout << "Email: "<<email[tmpCounter] << endl;
		cout << "Address: "<<address[tmpCounter] << endl << endl;
		cout << "Press any key to continue..." << endl << endl;
		getch();
	}
}

void print_all_contact(){
	if(counter > -1){
		for(int i=0; i<=counter; i++){
		    print_contact(i);
		}
	}
}

void update_contact(int tmpCounter){
     string tmpName = "";

	 cout << "Enter Name: ";
	 cin >> tmpName;

	 if(validate_contact(tmpName)){
	 	 name[tmpCounter] = tmpName;
	 }else{
	 	cout << endl << "Contact Already Exist with this Name" << endl;
	 	return;
	 }

     cout << "Enter Phone No: ";
     cin >> phoneNo[tmpCounter];
     cout << "Enter Mobile No: ";
     cin >> mobileNo[tmpCounter];
     cout << "Enter Fax: ";
     cin >> faxNo[tmpCounter];
     cout << "Enter Email: ";
     cin >> email[tmpCounter];
     cout << "Enter Address: ";
     cin >> address[tmpCounter];
}

void delete_contact(int tmpCounter){
	 name[tmpCounter] = "";
     phoneNo[tmpCounter] = "";
     mobileNo[tmpCounter] = "";
     faxNo[tmpCounter] = "";
     email[tmpCounter] = "";
     address[tmpCounter] = "";
}

int search_counter(){
	 if(counter < 0)
	 	 return -1;

	 string tmpName;

	 cout << "Enter Name: ";
	 cin >> tmpName;

	 for(int i = 0; i <= counter; i++){
	 	if(name[i] == tmpName){
	 		return i;
	 	}
	 }

 	 return 1;
}

int main(){

	char op;
	do{
		system("cls");
		cout << "1. Add Contact" << endl;
		cout << "2. View contact list" << endl;
		cout << "3. Search Contact" << endl;
		cout << "4. Update Contact" << endl;
		cout << "5. Delete Contact" << endl;
		cout << "6. Exit" << endl << endl;
		cout << "Enter Option from 1 to 6 : ";
		cin >> op;

		switch(op){
			case '1':
			{
				 add_contact();
				 cout << endl << "Contact added successful..." << endl;
				 cout << "Press any key to continue";
				 getch();
		 		 break;
			}

			case '2':
			{
				 print_all_contact();
		 		 break;
			}

			case '3':
			{
				 int tmpCounter = search_counter();
				 if(tmpCounter > -1){
				      print_contact(tmpCounter);
				 }
		 		 break;
			}

			case '4':
			{
				 int tmpCounter = search_counter();
				 if(tmpCounter > -1){
				      update_contact(tmpCounter);
				 }
		 		 break;
			}

			case '5':
			{
				 int tmpCounter = search_counter();
				 if(tmpCounter > -1){
				      delete_contact(tmpCounter);
				 }
		 		 break;
			}

			case '6':
			{
				 continue;
		 		 break;
			}
		}

	}while(op != '6');

	return 0;

}

Output and use of this phonebook management system program

Compile and run the above code to get the output and use this phonebook management system project. You will understand everything in your own. However, we have put one demo output for you. Let’s see this bellow;

1. Add Contact
2. View contact list
3. Search Contact
4. Update Contact
5. Delete Contact
6. Exit

Enter Option from 1 to 6 : 1
Enter Name: John
Enter Phone No: 0123456789
Enter Mobile No: 12345678910
Enter Fax No: 8478365
Enter Email No: john@gmail.com
Enter Address: California

Contact added successful...
Press any key to continue
1. Add Contact
2. View contact list
3. Search Contact
4. Update Contact
5. Delete Contact
6. Exit

Enter Option from 1 to 6 : 1
Enter Name: Doe
Enter Phone No: 49758474583
Enter Mobile No: 846374443
Enter Fax No: 8567395
Enter Email No: doe@gmail.com
Enter Address: Berlin

Contact added successful...
Press any key to continue
1. Add Contact
2. View contact list
3. Search Contact
4. Update Contact
5. Delete Contact
6. Exit

Enter Option from 1 to 6 : 2
Name: John
Phone No: 0123456789
Mobile No: 12345678910
Fax No: 8478365
Email: john@gmail.com
Address: California

Press any key to continue...

Name: Doe
Phone No: 49758474583
Mobile No: 846374443
Fax No: 8567395
Email: doe@gmail.com
Address: Berlin

Press any key to continue...

Now, you can search contact, update them and delete them as well. Enter 6 to exit the program.