MY CODE:
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#define SIZE 4
struct Employee {
int ID;
int AGE;
double SALARY;
};
int main(void) {
int option = 0,
i = 0,
employees = 0,
userID = 0,
new = 0,
flag = 0;
struct Employee emp[SIZE] = { { 0 } };
printf("---=== EMPLOYEE DATA ===---\n");
do {
printf("1. Display Employee Information\n");
printf("2. Add Employee\n");
printf("3. Update Employee Salary\n");
printf("4. Remove Employee\n");
printf("0. Exit\n\n");
printf("Please select from the above options: ");
scanf("%d", &option);
printf("\n");
switch (option) {
case 0:
printf("Exiting Employee Data Program. Goodbye!!!\n");
break;
case 1:
printf("EMP ID EMP AGE EMP SALARY\n");
printf("====== ======= ==========\n");
for (i = 0; i < SIZE && i >= 0; i++) {
if (emp[i].ID > 0) {
printf("%6d%9d%11.2lf", emp[i].ID, emp[i].AGE, emp[i].SALARY);
printf("\n");
}
}
break;
case 2:
printf("Adding Employee\n");
printf("===============\n");
if (employees < SIZE) {
printf("Enter employee ID: ");
scanf("%d", &emp[employees].ID);
printf("Enter employee Age: ");
scanf("%d", &emp[employees].AGE);
printf("Enter employee Salary: ");
scanf("%11lf", &emp[employees].SALARY);
employees++;
}
else {
printf("ERROR!!! Maximum Number of Employees Reached");
printf("\n");
}
break;
case 3:
do {
printf("Update Employee Salary\n");
printf("===========================\n");
printf("Enter Employee ID: ");
scanf("%d", &userID);
printf("\n");
for (i = 0; i < SIZE; i++) {
if (userID == emp[i].ID) {
printf("The current salary is %.2lf\n", emp[i].SALARY);
printf("Enter Employee New Salary: \n");
scanf("%lf", &emp[employees].SALARY);
flag = 1;
}
}
} while (flag != 1);
break;
case 4:
do {
printf("Remove Employee\n");
printf("===============\n");
printf("Enter Employee ID: ");
scanf("%d", &userID);
for (i = 0; i < SIZE - 1; i++)
{
if (userID == emp[i].ID) {
new = i;
}
}
while (new < SIZE)
{
if (new == SIZE - 1)
{
emp[new].ID = 0;
emp[new].AGE = 0;
emp[new].SALARY = 0;
}
else
{
emp[new] = emp[new + 1];
}
new++;
}
employees--;
printf("Employee %d will be removed\n", userID);
}
while (SIZE < i);
break;
default:
printf("ERROR: Incorrect Option: Try Again\n\n");
}
} while (option != 0);
return 0;
}
HOW WHAT I MAKE IT SO THAT IF I TYPE 3 THAN ENTER A EMPLOYEE ID THATS NOT FOUND. LIKE TEST FOR IT AND THAN PUT A PRINTF STATEMENT TO SAY IT DOESNT EXIST