Answer:
here is an example of how you can write the code for the Staff Information Module in a C programming text file:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_STAFF 50
typedef struct {
char staff_id[10];
char name[50];
char password[20];
char password_recovery[50];
char position[20];
} Staff;
Staff staff_list[MAX_STAFF];
int num_staff = 0;
void add_staff() {
if (num_staff == MAX_STAFF) {
printf("Maximum staff limit reached.\\");
return;
}
Staff new_staff;
printf("Enter staff ID: ");
scanf("%s", new_staff.staff_id);
printf("Enter name: ");
scanf("%s", new_staff.name);
printf("Enter password: ");
scanf("%s", new_staff.password);
printf("Enter password recovery: ");
scanf("%s", new_staff.password_recovery);
printf("Enter position: ");
scanf("%s", new_staff.position);
staff_list[num_staff] = new_staff;
num_staff++;
printf("Staff added successfully.\\");
}
void view_staff() {
if (num_staff == 0) {
printf("No staff to display.\\");
return;
}
printf("Staff ID\tName\tPosition\\");
for (int i = 0; i < num_staff; i++) {
printf("%s\t%s\t%s\\", staff_list[i].staff_id, staff_list[i].name, staff_list[i].position);
}
}
int main() {
int choice;
do {
printf("\\Staff Information Module\\");
printf("1. Add Staff\\");
printf("2. View Staff\\");
printf("3. Exit\\");
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice) {
case 1:
add_staff();
break;
case 2:
view_staff();
break;
case 3:
printf("Exiting Staff Information Module.\\");
break;
default:
printf("Invalid choice.\\");
}
} while (choice != 3);
return 0;
}
You can save this code in a text file with the extension ".c" and then compile and run it using a C compiler.