Can you please anwser these C++ questions , please make sure they are right. 1)
ID: 3874650 • Letter: C
Question
Can you please anwser these C++ questions , please make sure they are right.
1) What is the value of choice after the following statements?
void getChoice(int& par_choice, in par_count);
int choice, count=3;
getChoice(choice, count);
void getChoice(int& par_choice, in par_count)
{
if(par_count<0)
par_choice =0;
if(par_count = 0)
par_choice=-1;
else
par_choice=99;
return;
}
a. -1
b. 99
c. 3
d. 0
2) When parameters are passed between the calling code and the called function, parameters and arguments are matched by:
a. their relative positions in the parameter and argument lists
b. they are not matched up at all
c. their names
d. their data types
3) In the function declaration shown, the mechanism used to call this function is known as:
double pow(double base, double exp);
a. pass by name
b. pass by name
c. call by name
d. pass by value
Explanation / Answer
Ans1. Option B
explanation: Since the call to choice variable is done by passing its reference in the function. So, even though the return type is void, the changes made to the value of choice variable will be revealed after the function terminates.
Ans2. Option A (their relative positions in the parameter and argument lists)
Ans3. None of the options are correct because the mechanism used for calling the given function is known as call by value