Hospital Management System (C++ Code)
#include <iostream>
using namespace std;
int main() {
int choice;
string patientName[50];
int patientAge[50];
string patientDisease[50];
int patientCount = 0;
string doctorName[50];
string doctorSpec[50];
int doctorCount = 0;
do {
cout << "\n===== HOSPITAL MANAGEMENT SYSTEM =====\n";
cout << "1. Add Patient Record\n";
cout << "2. Display Patient Records\n";
cout << "3. Add Doctor Record\n";
cout << "4. Display Doctor Records\n";
cout << "5. Exit\n";
cout << "Enter your choice: ";
cin >> choice;
if (choice == 1) {
cout << "\nEnter Patient Name: ";
cin >> patientName[patientCount];
cout << "Enter Patient Age: ";
cin >> patientAge[patientCount];
cout << "Enter Disease: ";
cin >> patientDisease[patientCount];
patientCount++;
cout << "Patient record added successfully!\n";
}
else if (choice == 2) {
cout << "\n--- Patient Records ---\n";
for (int i = 0; i < patientCount; i++) {
cout << "Name: " << patientName[i]
<< ", Age: " << patientAge[i]
<< ", Disease: " << patientDisease[i] << endl;
}
}
else if (choice == 3) {
cout << "\nEnter Doctor Name: ";
cin >> doctorName[doctorCount];
cout << "Enter Specialization: ";
cin >> doctorSpec[doctorCount];
doctorCount++;
cout << "Doctor record added successfully!\n";
}
else if (choice == 4) {
cout << "\n--- Doctor Records ---\n";
for (int i = 0; i < doctorCount; i++) {
cout << "Name: " << doctorName[i]
<< ", Specialization: " << doctorSpec[i] << endl;
}
}
else if (choice == 5) {
cout << "Exiting program... Thank you!\n";
}
else {
cout << "Invalid choice! Try again.\n";
}
} while (choice != 5);
return 0;
}