Hospital Management System_FUNCTIONS
Hospital Management System_FUNCTIONS
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
// Constants
#define MAX_DOCTORS 5
#define MAX_PATIENTS 10
// Function Prototypes
void displayMenu();
int main() {
"Dr. Smith", "Dr. Johnson", "Dr. Lee", "Dr. Brown", "Dr. White"
};
char specializations[MAX_DOCTORS][MAX_NAME_LEN] = {
};
int patientCount = 0;
displayMenu();
return 0;
void displayMenu() {
printf("\nHospital Management System\n");
printf("6. Exit\n");
printf("----------------------------\n");
char doctorName[MAX_NAME_LEN];
char patientName[MAX_NAME_LEN];
int slot;
scanf("%d", &slot);
if (strcmp(doctors[i], doctorName) == 0) {
doctorIndex = i;
break;
}
if (doctorIndex == -1) {
return;
return;
strcpy(patients[*patientCount], patientName);
strcpy(patientDoctors[*patientCount], doctorName);
patientSlots[*patientCount] = slot;
(*patientCount)++;
availableSlots[doctorIndex]--;
printf("\nAppointment successful for %s with Dr. %s on Slot %d.\n", patientName, doctorName, slot);
printf("\nList of Appointments:\n");
if (patientCount == 0) {
} else {
printf("----------------------------\n");
return;
char patientName[MAX_NAME_LEN];
strcpy(patients[*patientCount], patientName);
(*patientCount)++;
char patientName[MAX_NAME_LEN];
int found = 0;
if (strcmp(patients[i], patientName) == 0) {
printf("----------------------------\n");
found = 1;
break;
}
if (!found) {
if (choice == 1) {
} else if (choice == 2) {
} else if (choice == 3) {
} else if (choice == 4) {
addPatient(patients, patientCount);
} else if (choice == 5) {
} else if (choice == 6) {
} else {
}
// Recursively call the menu to allow another action
displayMenu();
int newChoice;
scanf("%d", &newChoice);
Output
Hospital Management System
2. Make Appointment
3. View Appointments
4. Add Patient
5. View Patient
6. Exit
Specialization: Cardiologist
Available Slots: 5
----------------------------
Specialization: Neurologist
Available Slots: 3
----------------------------
Specialization: Orthopedic
Available Slots: 4
----------------------------
Specialization: Pediatrician
Available Slots: 2
----------------------------
Specialization: Dermatologist
Available Slots: 6
----------------------------
2. Make Appointment
3. View Appointments
4. Add Patient
5. View Patient
6. Exit
2. Make Appointment
3. View Appointments
4. Add Patient
5. View Patient
6. Exit
List of Appointments:
Appointment Slot: 2
----------------------------
2. Make Appointment
3. View Appointments
4. Add Patient
5. View Patient
6. Exit
2. Make Appointment
3. View Appointments
4. Add Patient
5. View Patient
6. Exit
Patient: Alice
Appointment Slot: 0
----------------------------
2. Make Appointment
3. View Appointments
4. Add Patient
5. View Patient
6. Exit
Start
2. Make Appointment
3. View Appointments
4. Add Patient
5. View Patient
6. Exit
If choice is 1:
If choice is 2:
o Ask for patient's name, doctor's name, and preferred appointment slot.
o Check if the doctor exists and if the slot is valid.
If choice is 3:
If choice is 4:
If choice is 5:
If choice is 6:
Pseudocode
START
Initialize patientCount = 0
DISPLAY MENU
IF doctor is found:
ELSE:
ELSE:
INCREMENT patientCount
IF patient is found:
ELSE:
EXIT program
END
Flowchart