Posts

Differentiate between message passing and function call.

Function Call Definition: A function call is a mechanism used to execute a specific block of code (a function or method) within the same program or class. It involves invoking a function by its name and passing any required parameters. Characteristics: Context : Function calls are typically used within the same program or class. They operate in the context of a single application's memory space. Direct Invocation : When you call a function, you directly invoke it using its name and pass arguments if needed. The function executes and may return a value. Syntax : In C++: result = functionName(parameters); In Python: result = functionName(parameters) Scope : Function calls are used to execute code within the same scope or context (e.g., within the same class or module). Implementation : The calling code and the function implementation are part of the same application. Function calls are resolved at compile time (in statically typed languages) or at runtime (in dynamically typed langua...
Write a C++ program using classes and object to simulate result preparation system for 20 students. The data available for each student include roll no, name and marks in three subject. The percentage marks and grade are to be calculated from the above information. The percentage marks are the average marks and the grade is calculated as follows: % Marks Grade <50 'F >50<60 ‘D’ >60<75 'C' >75<90 'B' >=90<100 ‘A’  Here is a C++ program that simulates a result preparation system for 20 students using classes and objects. The program calculates the percentage marks and assigns grades based on the given criteria: # include <iostream> # include <string> # include <vector> using namespace std; class Student { private : int rollNo; string name; float marks[ 3 ]; float percentage; char grade; void calculatePercentage () { float total = 0 ; for ( int i = 0 ; i < 3 ; ...

Reading name, post and salary of 10 different employees and displaying those records whose salary is greater than 10000 using user defined function c++

Reading name, post and salary of 10 different employees and displaying those records whose salary is greater than 10000 using user defined function c++ #include <iostream> #include <string> struct Employee {     std::string name;     std::string post;     double salary; }; // Function to display records with salary greater than 10000 void displayHighSalaryEmployees(Employee employees[], int size) {     std::cout << "Employees with salary greater than 10000:\n";     for (int i = 0; i < size; ++i) {         if (employees[i].salary > 10000) {             std::cout << "Name: " << employees[i].name << "\n";             std::cout << "Post: " << employees[i].post << "\n";             std::cout << "Salary: " << employees[i].salary << "\n\n";     ...

Multipath inheritance :There are 2 Ways to Avoid this Ambiguity:

  6. A special case of hybrid inheritance: Multipath inheritance :  A derived class with two base classes and these two base classes have one common base class is called multipath inheritance. Ambiguity can arise in this type of inheritance.  Example: CPP // C++ program demonstrating ambiguity in Multipath // Inheritance   #include <iostream> using namespace std;   class ClassA { public :      int a; };   class ClassB : public ClassA { public :      int b; };   class ClassC : public ClassA { public :      int c; };   class ClassD : public ClassB, public ClassC { public :      int d; };   int main() {      ClassD obj;        // obj.a = 10;                  // Statement 1, Error      // obj.a = 100...