Can you just give a comment in short on what is this about . Or just give a comment on how dose it run. #include #define MAX_EMP 5 #include "employee.h" int count = 0; struct Employee emp[MAX_EMP]; void display() { printf("\n---=== EMPLOYEE DATA ===---\n"); printf("EMP ID\tEMP AGE\tEMP SALARY\n"); printf("======\t=======\t==========\n"); for(int i = 0; i < count; i++) { printf("%d\t%d\t%.2f\n", emp[i].id, emp[i].age, emp[i].salary); } } void add() { if(count == MAX_EMP) { printf("\nERROR!!! Maximum Number of Employees Reached\n"); return; } printf("\nAdding Employee ===============\n"); printf("Enter Employee ID: "); scanf("%d", &emp[count].id); printf("Enter Employee Age: "); scanf("%d", &emp[count].age); printf("Enter Employee Salary: "); scanf("%f", &emp[count].salary); count++; } void update() { int id, found = 0; float newSalary; printf("\nUpdate Employee Salary ======================\n"); printf("Enter Employee ID: "); scanf("%d", &id); for(int i = 0; i < count; i++) { if(emp[i].id == id) { found = 1; printf("The current salary is %.2f\n", emp[i].salary); printf("Enter Employee New Salary: "); scanf("%f", &newSalary); emp[i].salary = newSalary; break; } } if(!found) { printf("* ERROR: Employee ID not found! *\n"); } } void Remove() { int id, found = 0, index; printf("\nRemove Employee ===============\n"); printf("Enter Employee ID: "); scanf("%d", &id); for(int i = 0; i < count; i++) { if(emp[i].id == id) { found = 1; index = i; break; } } if(!found) { printf("* ERROR: Employee ID not found! *\n"); return; } for(int i = index; i < count-1; i++) { emp[i] = emp[i+1]; } count--; printf("Employee %d will be removed\n", id); } int main() { int choice; while(1) { printf("\n1. Display Employee Information\n"); printf("2. Add Employee\n"); printf("3. Update Employee Salary\n"); printf("4. Remove Employee\n"); printf("0. Exit\n"); printf("\nEnter choice: "); scanf("%d", &choice); switch(choice) { case 0: printf("Exiting Employee Data Program. Good Bye!!!"); return 0; case 1: display(); break; case 2: add(); break; case 3: update(); break; case 4: Remove(); break; default: printf("ERROR: Incorrect Option: Try Again"); } } return 0; }
Can you just give a comment in short on what is this about . Or just give a comment on how dose it run. #include #define MAX_EMP 5 #include "employee.h" int count = 0; struct Employee emp[MAX_EMP]; void display() { printf("\n---=== EMPLOYEE DATA ===---\n"); printf("EMP ID\tEMP AGE\tEMP SALARY\n"); printf("======\t=======\t==========\n"); for(int i = 0; i < count; i++) { printf("%d\t%d\t%.2f\n", emp[i].id, emp[i].age, emp[i].salary); } } void add() { if(count == MAX_EMP) { printf("\nERROR!!! Maximum Number of Employees Reached\n"); return; } printf("\nAdding Employee ===============\n"); printf("Enter Employee ID: "); scanf("%d", &emp[count].id); printf("Enter Employee Age: "); scanf("%d", &emp[count].age); printf("Enter Employee Salary: "); scanf("%f", &emp[count].salary); count++; } void update() { int id, found = 0; float newSalary; printf("\nUpdate Employee Salary ======================\n"); printf("Enter Employee ID: "); scanf("%d", &id); for(int i = 0; i < count; i++) { if(emp[i].id == id) { found = 1; printf("The current salary is %.2f\n", emp[i].salary); printf("Enter Employee New Salary: "); scanf("%f", &newSalary); emp[i].salary = newSalary; break; } } if(!found) { printf("* ERROR: Employee ID not found! *\n"); } } void Remove() { int id, found = 0, index; printf("\nRemove Employee ===============\n"); printf("Enter Employee ID: "); scanf("%d", &id); for(int i = 0; i < count; i++) { if(emp[i].id == id) { found = 1; index = i; break; } } if(!found) { printf("* ERROR: Employee ID not found! *\n"); return; } for(int i = index; i < count-1; i++) { emp[i] = emp[i+1]; } count--; printf("Employee %d will be removed\n", id); } int main() { int choice; while(1) { printf("\n1. Display Employee Information\n"); printf("2. Add Employee\n"); printf("3. Update Employee Salary\n"); printf("4. Remove Employee\n"); printf("0. Exit\n"); printf("\nEnter choice: "); scanf("%d", &choice); switch(choice) { case 0: printf("Exiting Employee Data Program. Good Bye!!!"); return 0; case 1: display(); break; case 2: add(); break; case 3: update(); break; case 4: Remove(); break; default: printf("ERROR: Incorrect Option: Try Again"); } } return 0; }
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Can you just give a comment in short on what is this about . Or just give a comment on how dose it run.
#include
#define MAX_EMP 5
#include "employee.h"
int count = 0;
struct Employee emp[MAX_EMP];
void display() {
printf("\n---=== EMPLOYEE DATA ===---\n");
printf("EMP ID\tEMP AGE\tEMP SALARY\n");
printf("======\t=======\t==========\n");
for(int i = 0; i < count; i++) {
printf("%d\t%d\t%.2f\n", emp[i].id, emp[i].age, emp[i].salary);
}
}
void add() {
if(count == MAX_EMP) {
printf("\nERROR!!! Maximum Number of Employees Reached\n");
return;
}
printf("\nAdding Employee ===============\n");
printf("Enter Employee ID: ");
scanf("%d", &emp[count].id);
printf("Enter Employee Age: ");
scanf("%d", &emp[count].age);
printf("Enter Employee Salary: ");
scanf("%f", &emp[count].salary);
count++;
}
void update() {
int id, found = 0;
float newSalary;
printf("\nUpdate Employee Salary ======================\n");
printf("Enter Employee ID: ");
scanf("%d", &id);
for(int i = 0; i < count; i++) {
if(emp[i].id == id) {
found = 1;
printf("The current salary is %.2f\n", emp[i].salary);
printf("Enter Employee New Salary: ");
scanf("%f", &newSalary);
emp[i].salary = newSalary;
break;
}
}
if(!found) {
printf("* ERROR: Employee ID not found! *\n");
}
}
void Remove() {
int id, found = 0, index;
printf("\nRemove Employee ===============\n");
printf("Enter Employee ID: ");
scanf("%d", &id);
for(int i = 0; i < count; i++) {
if(emp[i].id == id) {
found = 1;
index = i;
break;
}
}
if(!found) {
printf("* ERROR: Employee ID not found! *\n");
return;
}
for(int i = index; i < count-1; i++) {
emp[i] = emp[i+1];
}
count--;
printf("Employee %d will be removed\n", id);
}
int main() {
int choice;
while(1) {
printf("\n1. Display Employee Information\n");
printf("2. Add Employee\n");
printf("3. Update Employee Salary\n");
printf("4. Remove Employee\n");
printf("0. Exit\n");
printf("\nEnter choice: ");
scanf("%d", &choice);
switch(choice) {
case 0:
printf("Exiting Employee Data Program. Good Bye!!!");
return 0;
case 1:
display();
break;
case 2:
add();
break;
case 3:
update();
break;
case 4:
Remove();
break;
default:
printf("ERROR: Incorrect Option: Try Again");
}
}
return 0;
}
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education