#include #include #include using namespace std; bool check = true; struct node { char name[20]; char jobtitle[20]; int empno; char branch; node *next; }*head,*lastptr; // pointes void add() // calling { node *p; //*p pomiter p=new node; cout<<"Enter name of employ:"<name); cout<<"Enter job title of employ:"<jobtitle); cout<<"Enter Number of employ:"<>p->empno; cout<<"Enter branch of employ:"<>p->branch; p->next=NULL; if(check) //if check is true its means heads is empty and there is no node exist. { head = p; lastptr = p; check = false; } else { lastptr->next=p; lastptr=p; } cout<>e_no; prev=head; current=head; while(current->empno!=e_no) { prev=current; current=current->next; } ptr=new node; cout<<"Enter name of employ:"<name); cout<<"Enter job title of employ:"<jobtitle); cout<<"Enter Number of employ:"<>ptr->empno; cout<<"Enter branch of employ:"<>ptr->branch; prev->next=ptr; ptr->next=current->next; current->next=NULL; delete current; cout<>e_no; prev=head; current=head; while(current->empno!=e_no) { prev=current; current=current->next; } cout<<"\nname: "; puts(current->name); cout<<"\nEmp No:"; cout<empno; cout<<"\njob title:"; puts(current->jobtitle); cout<<"\nbranch:"; cout<branch; } void del() { node *ptr=NULL; node *prev=NULL; node *current=NULL; int e_no; cout<<"Enter Number to Delete:"<>e_no; prev=head; current=head; while(current->empno!=e_no) { prev=current; current=current->next; } prev->next = current->next; current->next=NULL; delete current; cout<
#include <conio.h>
#include <iostream>
#include <string>
using namespace std;
bool check = true;
struct node
{
char name[20];
char jobtitle[20];
int empno;
char branch;
node *next;
}*head,*lastptr; // pointes
void add() // calling
{
node *p; //*p pomiter
p=new node;
cout<<"Enter name of employ:"<<endl;
gets(p->name);
cout<<"Enter job title of employ:"<<endl;
gets(p->jobtitle);
cout<<"Enter Number of employ:"<<endl;
cin>>p->empno;
cout<<"Enter branch of employ:"<<endl;
cin>>p->branch;
p->next=NULL;
if(check) //if check is true its means heads is empty and there is no node exist.
{
head = p;
lastptr = p;
check = false;
}
else
{
lastptr->next=p;
lastptr=p;
}
cout<<endl<<"Recored Entered";
}
void modify()
{
node *ptr;
node *prev=NULL;
node *current=NULL;
int e_no;
cout<<"Enter Number to search:"<<endl;
cin>>e_no;
prev=head;
current=head;
while(current->empno!=e_no)
{
prev=current;
current=current->next;
}
ptr=new node;
cout<<"Enter name of employ:"<<endl;
gets(ptr->name);
cout<<"Enter job title of employ:"<<endl;
gets(ptr->jobtitle);
cout<<"Enter Number of employ:"<<endl;
cin>>ptr->empno;
cout<<"Enter branch of employ:"<<endl;
cin>>ptr->branch;
prev->next=ptr;
ptr->next=current->next;
current->next=NULL;
delete current;
cout<<endl<<"Recored Modified";
getch();
}
void search() //searches record of employ//
{
node *prev=NULL;
node *current=NULL;
int e_no;
cout<<"Enter Number to search:"<<endl;
cin>>e_no;
prev=head;
current=head;
while(current->empno!=e_no)
{
prev=current;
current=current->next;
}
cout<<"\nname: ";
puts(current->name);
cout<<"\nEmp No:";
cout<<current->empno;
cout<<"\njob title:";
puts(current->jobtitle);
cout<<"\nbranch:";
cout<<current->branch;
}
void del()
{
node *ptr=NULL;
node *prev=NULL;
node *current=NULL;
int e_no;
cout<<"Enter Number to Delete:"<<endl;
cin>>e_no;
prev=head;
current=head;
while(current->empno!=e_no)
{
prev=current;
current=current->next;
}
prev->next = current->next;
current->next=NULL;
delete current;
cout<<endl<<"Recored Deleted";
}
int main()
{
char x;
cout<<"\t\t Employ MANAGEMENT SYSTEM \t\t\t"<<endl;
do
{
system("cls");
cout<<"1-Press '1' to add New record:"<<endl;
cout<<"2-Press '2' to search a record:"<<endl;
cout<<"3-Press '3' to modify a record:"<<endl;
cout<<"4-Press '4' to delete a record:"<<endl;
cout<<"5-Press '5' to exit:"<<endl;
x=getch();
if(x=='1')
{
system("cls");
add();
}
else if(x=='2')
{
system("cls");
search();
}
else if(x=='3')
{
system("cls");
modify();
}
else if(x=='4')
{
system("cls");
del();
}
else if(x=='5')
{
exit(0);
}
else
{
}
}while(x != 27);
getch();
}
Explain this program in detail....which functions are used in it and why they are used explain each and everything.
Step by step
Solved in 2 steps