Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Analyze the following code. int max( const int numb1, int& numb2 ) { int local_n

ID: 3692440 • Letter: A

Question

Analyze the following code.


int max( const int numb1, int& numb2 )
{

     int local_number = 911;
     numb2++;
     return local_number;
}

numb2 is a pass-by-value parameter and cannot be changed

numb2 is a non-const pass-by-reference parameter and can be changed in the function, and any changes made to it in the someFunction(...) function will persist beyond the scope of the function someFunction(...)

numb1 is a constant parameter and cannot be changed

numb1 is a constant parameter and can be changed in the function

numb2 is a pass-by-value parameter and cannot be changed

numb2 is a non-const pass-by-reference parameter and can be changed in the function, and any changes made to it in the someFunction(...) function will persist beyond the scope of the function someFunction(...)

numb1 is a constant parameter and cannot be changed

numb1 is a constant parameter and can be changed in the function

Explanation / Answer

int max( const int numb1, int& numb2 )
{
int local_number = 911;
numb2++;
return local_number;
}

1. numb2 is a pass-by-value parameter and cannot be changed: false, because it is also constant
2. numb2 is a non-const pass-by-reference parameter and can be changed in the function,
   and any changes made to it in the someFunction(...) function will persist beyond the
   scope of the function someFunction(...) : false, because this is true if and only if numb2 is
   passed in someFunction(...) by refrence
  
3. numb1 is a constant parameter and cannot be changed : true
4. numb1 is a constant parameter and can be changed in the function: false