The correct answer is: A. must include the address-of (&) operator before the array’s name.
When you pass an array by reference, you are passing the address of the array to the function. This means that the function can modify the elements of the array. To pass an array by reference, you must include the address-of (&) operator before the array’s name.
For example, the following code passes the array arr
by reference to the function change_array()
:
“`c
int arr[] = {1, 2, 3};
void change_array(int *arr) {
arr[0] = 10;
}
int main() {
change_array(arr);
printf(“%d\n”, arr[0]); // prints 10
}
“`
In this example, the function change_array()
modifies the element at index 0 of the array arr
. The change is visible in the main function because the array arr
is passed by reference.
Options B and C are incorrect because they do not include the address-of (&) operator. Option D is incorrect because arrays are not automatically passed by reference.