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

dsal11

The document is a C++ program for an Employee Management System that allows users to insert, delete, and search employee records. It defines a structure for employee details and provides a menu-driven interface for managing employee data. The program limits the number of entries to a maximum of 20 and includes functions for handling various operations on the employee records.

Uploaded by

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

dsal11

The document is a C++ program for an Employee Management System that allows users to insert, delete, and search employee records. It defines a structure for employee details and provides a menu-driven interface for managing employee data. The program limits the number of entries to a maximum of 20 and includes functions for handling various operations on the employee records.

Uploaded by

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

NAME: KUNDAN DHOKE DATE:

DIV : B
ROLL NO.: 20
-----------------------------------------------------------------------------------------
PRACTICAL NO. : 11
#include <bits/stdc++.h>

#define max 20
using namespace std;

struct employee {
string name;
long int code;
string designation;
int sal;

};

int num;
void showMenu();

employee emp[max], tempemp[max],


sortemp[max], sortemp1[max];

void build()
{
cout << "Maximum Entries can be "<< max << "\n";

cout << "Enter the number of Entries required: ";


cin >> num;

if (num > 20) {


cout << "Maximum number of Entries are 20.\n";
num = 20;
}
cout << "Enter the following data:\n";

for (int i = 0; i < num; i++) {


cout << "Name: ";
cin >> emp[i].name;

cout << "Employee ID: ";


cin >> emp[i].code;

cout << "Designation: ";


cin >> emp[i].designation;

cout << "Salary: ";


cin >> emp[i].sal;

}
showMenu();
}

void insert()
{
if (num < max) {
int i = num;
num++;

cout << "Enter the information of the Employees.\n";


cout << "Name: ";
cin >> emp[i].name;

cout << "Employee ID: ";


cin >> emp[i].code;

cout << "Designation: ";


cin >> emp[i].designation;

cout << "Salary ";


cin >> emp[i].sal;

}
else {
cout << "Employee Size Full\n";
}
showMenu();
}

// Function to delete record at index i


void deleteIndex(int i)
{
for (int j = i; j < num - 1; j++) {
emp[j].name = emp[j + 1].name;
emp[j].code = emp[j + 1].code;
emp[j].designation = emp[j + 1].designation;
emp[j].sal = emp[j + 1].sal;

}
return;
}

// Function to delete record


void deleteRecord()
{
cout << "Enter the Employee ID to Delete Record: ";
int code;
cin >> code;
for (int i = 0; i < num; i++) {
if (emp[i].code == code) {
deleteIndex(i);
num--;
break;
}
}
showMenu();
}

void searchRecord()
{
cout << "Enter the Employee ID to Search Record: ";

int code;
cin >> code;

for (int i = 0; i < num; i++) {

// If the data is found


if (emp[i].code == code) {
cout << "Name: "
<< emp[i].name << "\n";

cout << "Employee ID: "


<< emp[i].code << "\n";

cout << "Designation: "


<< emp[i].designation << "\n";

cout << "Salary: "


<< emp[i].sal << "\n";

break;
}
}

showMenu();
}

void showMenu()
{
cout << "------------------------- Employee Management System -----------------------
--\n\n";
cout << "Available Options:\n\n";
cout << "Insert New Entry (1)\n";
cout << "Delete Entry (2)\n";
cout << "Search a Record (3)\n";
cout << "Exit (4)\n";

int option;
cin >> option;

if (option == 1) {
insert();
}
else if (option == 2) {
deleteRecord();
}
else if (option == 3) {
searchRecord();
}
else if (option == 4) {
return;
}
else {
cout << "Expected Options are 1 to 4";
showMenu();
}
}

int main()
{
showMenu();
return 0;
}

Output:

You might also like