Posts

Showing posts from August, 2024

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 ; ...