Consider the following function and code segment.
```
void One( int first, int & second )
{
first = 17;
second = first + 1;
}
int main()
{
// other code ...
int j = 4;
int k = 3;
One(j, k);
// other code ..
}
```
After the call to One(j, k); what are the values of j and k? Why?
a) j == 4, k == 3;
b) j == 17, k == 18;
c) j == 4, k == 18;
d) j == 17, k == 3;
c) j == 4, k == 18;
The first parameter is called by value, so the parameter first is assigned 4 by the call. The parameter first is immediately assigned in the function, but the first argument is not changed, hence, j==4.
The second parameter is call-by-reference, so when first + 1 is computed to be 18, and is assigned to second, second is changed, and the corresponding argument, k is changed, hence, k==18.
You might also like to view...
A type of computer operating system user interface that is commonly used today is ________.
a. command line b. voice command c. menu driven d. graphical (GUI)
The ________ topology uses tokens to control data transmission
Fill in the blank(s) with correct word