79.8k views
1 vote
to simulate call by reference when passing a non-array variable to a function, it is necessary to pass the _____ of the variable to the function.

1 Answer

5 votes

Answer:

When passing a variable that is not an array to a function, the memory address of the variable must be passed to the function in order to simulate call by reference.

In other words, instead of giving the function the value of the variable directly, we give it a pointer to where the variable is stored in memory. This lets the function directly access the memory where the variable is stored and change its contents.

In languages like C and C++, this is usually done by giving the function a pointer to the variable.

User Timsterc
by
8.3k points

No related questions found