Hospital Management System in C++ - GeeksforGeeks
Hospital Management System in C++ - GeeksforGeeks
Functions Supported:
Approach:
https://www.geeksforgeeks.org/hospital-management-system-in-c/ 12/03/24, 3 00 PM
Page 1 of 17
:
Create
classes
for both the Hospital dataset and Patient data.
Initialize variables that store Hospital dataset and Patient data.
Create
Objects
for hospitals and Patient classes that access the Hospital dataset and Patient
data.
use two
arrays
that hold the Hospital dataset and Patient data.
Implement the given functionality as shown below.
C++
https://www.geeksforgeeks.org/hospital-management-system-in-c/ 12/03/24, 3 00 PM
Page 2 of 17
:
class Patient : public Hospital {
public:
string P_name;
int P_id;
};
// Hospital Data
void PrintHospitalData(
vector<Hospital>&
C++ Data hospitals)
Types C++ Input/Output C++ Arrays C++ Pointers C++ OOPs C++ STL C++ Interview
{
cout << "PRINT hospitals DATA:"
<< endl;
https://www.geeksforgeeks.org/hospital-management-system-in-c/ 12/03/24, 3 00 PM
Page 3 of 17
:
vector<Hospital>& hospitals)
{
cout << "PRINT patients DATA:"
<< endl;
cout << "Patient_Name "
<< "Patient_Id "
<< "Patient_Contact "
<< "Alloted_Hospital "
<< "Patient_Expenditure \n";
https://www.geeksforgeeks.org/hospital-management-system-in-c/ 12/03/24, 3 00 PM
Page 4 of 17
:
<< endl;
PrintHospitalData(hospitals);
}
PrintHospitalData(hospitals);
}
PrintHospitalData(hospitals);
}
https://www.geeksforgeeks.org/hospital-management-system-in-c/ 12/03/24, 3 00 PM
Page 5 of 17
:
// Comparator function to sort the
// hospital data by Bed Price
bool beds_price(Hospital& A, Hospital& B)
{
return A.price < B.price;
}
PrintHospitalData(hospitals);
}
if (hospitals[i].location != city)
continue;
cout << hospitals[i].H_name
<< " "
<< " "
<< hospitals[i].location
<< " "
<< hospitals[i].available_beds
https://www.geeksforgeeks.org/hospital-management-system-in-c/ 12/03/24, 3 00 PM
Page 6 of 17
:
<< " "
<< hospitals[i].rating
<< " "
<< hospitals[i].contact
<< " "
<< hospitals[i].doctor_name
<< " "
<< " "
<< hospitals[i].price
<< " "
<< endl;
}
cout << endl
<< endl;
}
https://www.geeksforgeeks.org/hospital-management-system-in-c/ 12/03/24, 3 00 PM
Page 7 of 17
:
// Initialize the data
for (int i = 0; i < 4; i++) {
p.P_name = patient_Name[i];
p.P_id = patient_Id[i];
p.contact = patient_Contact[i];
p.price = bookingCost[i];
patients.push_back(p);
}
SortHospitalByName(hospitals);
SortHospitalByRating(hospitals);
PrintHospitalBycity("Bangalore", hospitals);
SortByBedsAvailable(hospitals);
SortByBedsPrice(hospitals);
}
// Driver Code
int main()
{
// Stores hospital data and
// the user data
string patient_Name[] = { "P1", "P2", "P3", "P4" };
int patient_Id[] = { 2, 3, 4, 1 };
string patient_Contact[]
= { "234534XXX7", "234576XXX2", "857465XXX9",
"567657XXX0" };
int bookingCost[] = { 1000, 1200, 1100, 600 };
// Function Call
HospitalManagement(
patient_Name, patient_Id, patient_Contact,
bookingCost, hospital_Name, locations, beds,
https://www.geeksforgeeks.org/hospital-management-system-in-c/ 12/03/24, 3 00 PM
Page 8 of 17
:
ratings, hospital_Contact, doctor_Name, prices);
return 0;
}
Output:
https://www.geeksforgeeks.org/hospital-management-system-in-c/ 12/03/24, 3 00 PM
Page 9 of 17
:
Your options after clearing GATE Examinations can be:
1. Go for higher studies in prestigious IITs
2. Apply for job roles in PSUs or MNCs
3. Specialize further in AI or Cybersecurity
4. Take up teaching roles
5. And much more!
Sounds like something you wish to learn more about? Register for Free GATE
Counselling session with our experts and they shall guide you in the right
direction.
Also get assured GfG T-Shirts if you attend the counselling. Register Now.
NOTE: This service is exclusively for the students in Delhi/NCR Region as
the classroom program for GATE is in our Noida Center only. We are soon
coming up with more all across India!
Maximize your earnings for your published articles in Dev Scripter 2024!
Showcase expertise, gain recognition & get extra compensation while elevating
your tech profile.
https://www.geeksforgeeks.org/hospital-management-system-in-c/ 12/03/24, 3 00 PM
Page 10 of 17
:
Previous Next
Similar Reads
Hospital Management Application Hospital Appointment System using
using MERN Stack Express
ajaykr00kj
https://www.geeksforgeeks.org/hospital-management-system-in-c/ 12/03/24, 3 00 PM
Page 11 of 17
:
A-143, 9th Floor, Sovereign Corporate
Tower, Sector-136, Noida, Uttar Pradesh -
201305
Company
About Us
Legal
Careers
In Media
Contact Us
Advertise with us
Explore
Hack-A-Thon
DSA in JAVA/C++
Master CP
GeeksforGeeks Videos
Geeks Community
Languages
Python
Java
C++
https://www.geeksforgeeks.org/hospital-management-system-in-c/ 12/03/24, 3 00 PM
Page 12 of 17
:
C++
PHP
GoLang
SQL
R Language
Android Tutorial
DSA
Data Structures
Algorithms
DSA Roadmap
Competitive Programming
ML Maths
Pandas Tutorial
NumPy Tutorial
NLP Tutorial
Web Technologies
HTML
CSS
JavaScript
TypeScript
ReactJS
https://www.geeksforgeeks.org/hospital-management-system-in-c/ 12/03/24, 3 00 PM
Page 13 of 17
:
ReactJS
NextJS
NodeJs
Bootstrap
Tailwind CSS
Python
Python Programming Examples
Django Tutorial
Python Projects
Python Tkinter
Web Scraping
Computer Science
GATE CS Notes
Operating Systems
Computer Network
Software Engineering
Engineering Maths
DevOps
Git
AWS
Docker
Kubernetes
Azure
GCP
DevOps Roadmap
System Design
https://www.geeksforgeeks.org/hospital-management-system-in-c/ 12/03/24, 3 00 PM
Page 14 of 17
:
System Design
High Level Design
UML Diagrams
Interview Guide
Design Patterns
OOAD
Interview Questions
School Subjects
Mathematics
Physics
Chemistry
Biology
Social Science
English Grammar
Commerce
Accountancy
Business Studies
Economics
Management
HR Management
Finance
Income Tax
Polity Notes
Geography Notes
History Notes
Economy Notes
https://www.geeksforgeeks.org/hospital-management-system-in-c/ 12/03/24, 3 00 PM
Page 15 of 17
:
Economy Notes
Ethics Notes
Preparation Corner
Resume Templates
Aptitude Preparation
Puzzles
Company-Wise Preparation
Companies
Colleges
Competitive Exams
JEE Advanced
UGC NET
SSC CGL
SBI PO
SBI Clerk
IBPS PO
IBPS Clerk
More Tutorials
Software Development
Software Testing
Product Management
Project Management
Linux
Excel
https://www.geeksforgeeks.org/hospital-management-system-in-c/ 12/03/24, 3 00 PM
Page 16 of 17
:
Image Editor
Code Formatters
Code Converters
Currency Converter
Improve an Article
Internships
https://www.geeksforgeeks.org/hospital-management-system-in-c/ 12/03/24, 3 00 PM
Page 17 of 17
: