- True or False: It would be legal to have these two function prototypes in
the same program:
double f(int);
int f(int);
- True or False: It would be legal to have these two function prototypes in
the same program:
double f(int, int);
int f(int, double);
- True or False: Using a call-by-reference parameter, a function can obtain
the initial value of an argument variable as well as change the value of that
variable.
- Consider the following functions:
void Myst(int a, int& b)
{
a *= b;
b = 2 + a;
}
void Test()
{
int u = 2;
int v = 3;
Myst(u, v);
cout << u << " " << v << endl;
}
What is printed as a result of the call Test()?
| (a) |
2 3 |
| (b) |
2 8 |
| (c) |
6 3 |
| (d) |
6 8 |
| (e) |
8 3 |
- Assume that you are designing a program in which you need a void
function called readAndAverage that reads a given number of
double values and returns their average. The number of values to
process is read as user input into a variable in the main program. Write the
function prototype (only) for readAndAverage, using call-by-value or
call-by-reference parameters as appropriate.