Answer:
#include <iostream>
using namespace std;
class ProblemSolution {
private:
int num1, num2;
public:
ProblemSolution(int n1, int n2) {
num1 = n1;
num2 = n2;
}
int calculateSum() {
int sum = 0;
sum = num1 + num2;
return sum;
}
void printSum() {
// calculateSum will return sum value that will be printed here
cout <<"Sum = "<< calculateSum();
}
~ProblemSolution() {
cout << "\nDestructor is called " << endl;
};
};
int main() {
int a, b;
cout << "Enter a: ";
cin >> a;
cout << "Enter b: ";
cin >> b;
// Initiallizing object pointer of type ProblemSolution
ProblemSolution *objPtr = new ProblemSolution(a,b);
// printing Sum
objPtr->printSum();
// delete objPtr to relaease heap memory :important
delete objPtr;
return 0;
}
Explanation:
we will initialize a pointer "objPtr" and initallize the constructor by passing 2 values a and b followed by the keyword "new". the keyword "new" allocates memory in the heap. we can access class member functions using arrow "->". it is important to delete objPtr at the end of the program so that the heap memory can be freed to avoid memory leakage problems.
Answer:
15.7 ; 78.5
Explanation:
Mechanical advantage of a screw = Circumference / pitch
Circumference = pi × d
Where :
pi = 3.142, D = diameter
Therefore ;
Circumference = 3.142 × (1/4) = 0.785 in
Pitch = 1/TPI
TPI (thread per inch) = 20
Pitch = 1/ 20 = 0.05
Mechanical advantage = 0.785 / 0.05 = 15.7
Resistance force if effort force is 5lb
Mechanical advantage = Fr / Fe
Fe = effort force, Fr = resistance force
15.7 = Fr / 5
Fr = 15.7 × 5 = 78.5 lbs
Answer: I already answered this question here:
A computer is one type of machine manage different kinds of programs to perform useful tasks to the users. ... Computer contains wires, transistors, circuits, hardware parts and etc. Computer designs with both software and hardware. Software is a process of preparing program through instructions and data