Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<windows.h>
- struct node
- {
- int id,age;
- int phone_number[20];
- char name[100];
- float salary;
- struct node *next;
- }*head;
- void append()
- {
- printf("\n\nAdd Employee Record:\n");
- printf("___________________\n\n");
- struct node *temp;
- temp=(struct node*)malloc(sizeof(struct node));
- printf(" Enter ID:");
- scanf("%d",&temp->id);
- printf(" Enter Name:");
- scanf("%s",temp->name);
- printf(" Enter Age:");
- scanf("%d",&temp->age);
- printf(" Enter Basic Salary:");
- scanf("%f",&temp->salary);
- printf(" Enter Phone Number:");
- scanf("%s",&temp->phone_number);
- temp->next=NULL;
- if(head==NULL)
- {
- head=temp;
- }
- else
- {
- struct node *p;
- p=head;
- while(p->next!=NULL)
- {
- p=p->next;
- }
- p->next=temp;
- }
- system("CLS");
- printf(" *** Employee Added Successfully *****\n");
- Sleep(2000);
- system("CLS");
- }
- void search()
- {
- struct node *temp;
- int sid,flag=0;
- printf(" Enter Search ID:");
- scanf("%d",&sid);
- system("CLS\n");
- printf(" \n\n");
- printf(" ID NAME Age Salary Phone Number\t\n");
- temp=head;
- while(temp!=NULL)
- {
- if(temp->id==sid)
- {
- printf("%d ",temp->id);
- printf("%s ",temp->name);
- printf("%d ",temp->age);
- printf("%.2f ",temp->salary);
- printf("%s ",temp->phone_number);
- flag=1;
- break;
- }
- temp=temp->next;
- }
- if(flag==0)
- {
- printf("Not found\n");
- }
- printf("\nPress enter go to home page:\n");
- getchar();
- getchar();
- system("CLS");
- }
- void delete_info()
- {
- struct node *prev,*tem;
- tem = head;
- prev = head;
- int ID;
- printf("Enter Delete ID:\n");
- scanf("%d",&ID);
- while(tem->id != ID)
- {
- prev =tem;
- tem = tem->next;
- }
- if(prev==tem)
- {
- head = head->next;
- return;
- }
- prev->next = tem->next;
- free(tem);
- system("CLS");
- printf(" *** Employee Delete Successfully *****\n");
- Sleep(2000);
- system("CLS");
- }
- void update_data()
- {
- struct node *temp;
- int upid;
- printf(" How to Modify ID:");
- scanf("%d",&upid);
- temp = head;
- while(temp!=NULL)
- {
- if(temp->id==upid)
- {
- printf(" Enter New ID:");
- scanf("%d",&temp->id);
- printf(" Enter New Name:");
- scanf("%s",temp->name);
- printf(" Enter New Age:");
- scanf("%d",&temp->age);
- printf(" Enter New Salary:");
- scanf("%.2f",&temp->salary);
- printf(" Enter New Phone Number:");
- scanf("%s ",temp->phone_number);
- printf("\tID \tNAME \tAge \tSalary \tPhone Number\t\n");
- printf("%d ",temp->id);
- printf("%s ",temp->name);
- printf("%d ",temp->age);
- printf("%.2f ",temp->salary);
- printf("%s ",temp->phone_number);
- return;
- getchar();
- getchar();
- getchar();
- getchar();
- }
- temp = temp->next;
- }
- }
- void display()
- {
- printf("\tID \tNAME \tAge \tSalary \tPhone Number\t\n");
- struct node *p;
- p=head;
- while(p!=NULL)
- {
- printf("\t%d \t%s \t%d \t%.2f \t%s\t\n ",p->id,p->name,p->age,p->salary,p->phone_number);
- p=p->next;
- }
- printf("Press enter go to home page:\n");
- getchar();
- getchar();
- system("CLS");
- }
- int main()
- {
- int flag=0;
- while(1)
- {
- printf("\t\t\t***Employee Record System***\t\t\t\n ");
- printf("\t\t---------------------------------------\t\t\n\n");
- printf(" 1.Add Employee Record\n");
- printf(" 2.Display All Employee Record\n");
- printf(" 3.Search A Employee Record\n");
- printf(" 4.Delete Employee Record\n");
- printf(" 5.Modify Record\n");
- printf(" 6.Exits\n");
- printf(" Inter any number:");
- int n;
- scanf("%d",&n);
- switch(n)
- {
- case 1:
- system("CLS");
- append();
- break;
- case 2:
- system("CLS");
- display();
- break;
- case 3:
- system("CLS");
- search();
- break;
- case 4:
- system("CLS");
- delete_info();
- break;
- case 5:
- system("CLS");
- update_data();
- break;
- case 6:
- flag=1;
- break;
- default:
- system("CLS");
- printf("****Please Enter The Valid Input****\n");
- Sleep(2000);
- system("CLS");
- }
- if(flag==1)
- break;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement