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

How to call the functions as described? PART A // without saving the return valu

ID: 3648005 • Letter: H

Question

How to call the functions as described?

PART A
// without saving the return value call f4 with the first parameter 234
// the value of 235 should be printed
// STUDENT WRITES THE CODE

PART B
declare a pointer variable, call f4 with the first parameter 319
// and save the return value in the pointer variable
// then print the answer -- the value 320 should be printed


void f3(int parm, int * pointerToAnswer)
{

* pointerToAnswer = parm + 1;// DUMMY CODE TO GET TO COMPILE
}

int * f4(int parm)
{
parm = parm + 1;
int *pointer;
*pointer = parm;

return pointer; // DUMMY

Explanation / Answer

When a variable is passed by reference we are not passing a copy of its value, but we are somehow passing the variable itself to the function and any modification that we do to the local variables will have an effect in their counterpart variables passed as arguments in the call to the function

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote