Posts

Showing posts with the label Array of Objects

C++ Program to Load and Display Records of N Products Using Class (Inline Function)

In C++, a class can be used to store the details of multiple products. An array of objects allows us to create and manage records of N products. An inline member function can perform small operations, such as calculating profit or loss. C++ में Class का उपयोग करके अनेक Products का रिकॉर्ड स्टोर किया जा सकता है। Array of Objects की सहायता से हम N Products के रिकॉर्ड को इनपुट और प्रदर्शित कर सकते हैं। Inline Member Function का उपयोग Profit या Loss जैसी छोटी गणनाओं के लिए किया जा सकता है। C++ Program #include <iostream> #include <string> using namespace std; #define N 5 class Product { int pid; string pname; float costprice; float sellprice; // Inline member function void profitloss() { float pl = sellprice - costprice; if (pl > 0) { cout << "Profit = " << pl << endl; } else if (pl < 0) { cout << "Loss = " << -pl << e...

C++ Program to Load and Store Records of N Employees N कर्मचारियों के रिकॉर्ड को इनपुट एवं स्टोर करने का C++ प्रोग्राम

In C++, an array of objects can be used to store records of multiple employees. Each object represents one employee and stores information such as Employee ID, Name, and Basic Salary. We can also calculate different salary components such as Travel Allowance (TA), Dearness Allowance (DA), House Rent Allowance (HRA), and Gross Salary using member functions. C++ में Multiple Employees के Records को Store करने के लिए Array of Objects का उपयोग किया जा सकता है। प्रत्येक Object एक Employee को दर्शाता है तथा इसमें Employee ID, Name और Basic Salary जैसी जानकारियाँ Store की जाती हैं। Member Functions की सहायता से Travel Allowance (TA), Dearness Allowance (DA), House Rent Allowance (HRA) तथा Gross Salary की गणना भी की जा सकती है। Salary Calculation Formula (सैलरी कैलकुलेशन फॉर्मूला) TA = 25% of Basic Salary DA = 50% of Basic Salary HRA = 10% of Basic Salary Gross Salary = Basic Salary + TA + DA + HRA Program: #include <iostream> #include <string> #include <iomanip> using namesp...

C++ Program to Load and Store Records of N Students N विद्यार्थियों के रिकॉर्ड को इनपुट एवं स्टोर करने का C++ प्रोग्राम

In C++, an array of objects can be used to store records of multiple students. Each object represents one student and contains information such as Roll Number, Name, and Marks. By creating an array of objects, we can accept and display the records of multiple students using loops. C++ में Multiple Students के Records को Store करने के लिए Array of Objects का उपयोग किया जा सकता है। प्रत्येक Object एक Student को दर्शाता है तथा इसमें Roll Number, Name और Marks जैसी जानकारियाँ Store की जाती हैं। Objects का Array बनाकर Loops की सहायता से अनेक विद्यार्थियों के Records को Input तथा Display किया जा सकता है। Program: #include <iostream> #include <string> using namespace std; #define N 5 class Student { int rollno; string name; float marks; static int count; public: Student() { count++; } void setStudent(); void getStudent(); }; // Initializing static data member int Student::count = 0; // Function to accept student details void Student::set...