Question: INCLUDE COMMENTS FOR EVERY SINGLE LINE IN FOLLOWING PROGRAM (explain every step). #include #define MAX_PATIENTS 100 using namespace std; struct doctor { int doctor_id; bool

INCLUDE COMMENTS FOR EVERY SINGLE LINE IN FOLLOWING PROGRAM (explain every step).

#include #define MAX_PATIENTS 100 using namespace std; struct doctor { int doctor_id; bool status; }doctors[2] = { {1,0}, {2,0} }; struct patient { char patient_id; }patients[MAX_PATIENTS]; int patientsSize = 0; int doctors_available = 2;

void signup(); void login(); void consult();

void signup() { while (true) { cout << "Enter Patient ID" << endl; char id; cin >> id; id = toupper(id); bool check_If_Duplicate = false; if (isalpha(id)) { for (int i = 0; i < patientsSize; i++) { if (patients[i].patient_id == id) { cout << "This ID already Exists Try Again" << endl; check_If_Duplicate = true; break; }

} if (!check_If_Duplicate) { patients[patientsSize].patient_id = id; patientsSize++; cout << id << " Registered Successfully" << endl; break; }

} else { cout << "Please Enter Only Alphabets" << endl; } } } void consult() { int id; cout << "Enter Doctor ID" << endl; cin >> id; if (doctors[id - 1].status == 0) { cout << "Doctor No. " << id << " Will Contact You" << endl; doctors[id - 1].status = 1; } else { if (id == 1) { if (doctors[1].status == 0) { cout << "Sorry Doctor No 1 is assigned to another patient " << endl; cout << "Doctor No 2 will contanct you now" << endl; doctors[1].status = 1; } else { cout << "Sorry No Doctor Is Available" << endl; } } else if (id == 2) { if (doctors[0].status == 0) { cout << "Sorry Doctor No 2 is assigned to another patient " << endl; cout << "Doctor No 2 will contanct you now" << endl; doctors[0].status = 1; } else { cout << "Sorry No Doctor Is Available" << endl; } } }

} void login() { int loginCount = 0; while (true) {

char id; cout << "Enter Login id" << endl; cin >> id; bool check_If_Id_Exists = false; for (int i = 0; i < patientsSize; i++) { if (patients[i].patient_id == id) { check_If_Id_Exists = true; break; } } if (check_If_Id_Exists) { cout << id << " Logged In Succesfully" << endl; consult(); break; } else { cout << "Wrong ID: re-Enter ID" << endl; loginCount++; if (loginCount > 3) { cout << "You are not a registered patient sign up first" << endl; break; } }

} } int main() { patients[0].patient_id = 'A'; patients[1].patient_id = 'B'; patientsSize = 2;

while (true) { cout << "1 To Register In TMC" << endl; cout << "2 To Login" << endl; cout << "3 To Exit" << endl; cout << "Your Selection: "; int choice; cin >> choice; if (choice == 1)

signup(); else if (choice == 2) login(); else if (choice == 3) break; } return 0; }

why #define is used?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!