Please help in pointing me in the right direction so I can actually start the questions.
I am posting my questions here for experts to help me understand what I am meant to do in each specified question.
This subject is not my major.
Your help in this matter would be greatly appreciated.
Q1.
Function callings are indispensible in just about every C++ program that is supposed to be able to achieve something non-trivial. To refresh ourselves, explain the difference between passing by value and passing by reference in function calling. Use your own concrete C++ code to exemplify your explanations.
>>>>>>>I dont quite understand the question.
c++ code
#include <iostream>
using namespace std;
int main ()
{
?????????????
int a=1,b=2;
do i do a loop ???
Q2.
This is for the implementation of the menu options 1. to 3.. For simplicity, we assume that the total number of marks to be analysed will not exceed 1000 within the program. When menu option 1. is selected, the program will let you add just one mark before returning you to the menu. When menu option 2. is selected, the program will list all the marks which have been added so far, some of which may be equal in value, then pause the screen for viewing before returning to the menu again. When menu option 3. is selected, the program will calculate and display the average of all the added marks, before returning again to the menu. You are welcome to design your program in whichever way you wish, as long as it is consistent with the general design principles. However, you are also welcome to implement the following prototyped functions or their variants for this purpose
16. bool addMark(double allMarks[], int &totalRec, double &mark);
17. bool displayMarks(double allMarks[], int totalRec);
18. bool findMean(double allMarks[], int totalRec, double &mean);
where the array allMarks is assumed to contain totalRec number of valid marks, mark may be used to pass back the actual mark successfully added, and mean may be used to pass back the average of all the marks. The bool value returned by a function may be used to indicate whether the operation has been successful or not.
>>>>>> I don't even understand this question (NEED HELP) but,
Code:
#include <iostream>
bool isPrimeNumber(long);
int main(void)
{
int numPrimesFound = 0;
for (long i = 2; i < 1000; i++)
{
if (isPrimeNumber(i))
{
numPrimesFound++;
std::cout << "Prime #" << numPrimesFound << ": " << i << std::endl;
}
}
return 0;
}
bool isPrimeNumber(long num)
{
if (num < 2)
return false;
else if (num == 2)
return true;
else
{
for (long i = 2; i < num; i++)
{
if (num % i == 0)
return false;
}
}
system ("pause");
return true;
}
This is for the implementation of the menu options 6. and 7.. When menu option 6. is selected, the program will first read a mark from the user, and then search the available list of marks to see how many occurrences of this mark there are. It will then report this number of occurrences. When menu option 7. is selected, the program will go through all the distinctive marks in the list, and find out how many occurences there are for each of the distinctive marks. For instance, if the current list of marks contains
24. 56, 67, 86, 56, 56, 67, 77
then the menu option 7. should generate something similar to
MARKS OCCURRENCES
56 3
67 2
86 1
77 1
>>>> I need someone to explain this question, as I don't understand it... ????

