1 int boot 10 2 int x 3 y foox 4 y fooboot5 5 y foox 6 y
1. int boot [10];
2. int x;
3. y = foo(x);
4. y = foo(boot[5]);
5. y = foo(&x);
6. y = foo(boot);
7. y= foo(boot,10);
Illustration5: Function calls
Illustration 5: Which line calls a function with the name of an array?
Solution
Please follow the data and description :
Arrays in C :
Arrays are always passed by reference in C. They do not use the \'&\' notation, but are pass by reference. For example please find the below code for a clear picture :
CODE :
void arrayData( int array_variable[], int length_of_array )
{
for (int i=0; i<length_of_array; i++)
{
array_variable[i] = i;
}
}
// Test code for passing an array by reference
int main()
{
int values[50];
printf(\"the value at location 7 starts as %d\ \", values[7]);
arrayData(values, 50); // function calls
printf(\"the value at location 7 is now %d\ \", values[7]);
return 0;
}
When noticed clearly the line with the comment function calls we see that the function in the code has been called by passing the array name that is locally declared and with the respective size of the array which is the basic sytanx for the calling of a function with the array data as a parameter.
So for the given example the line y= foo(boot,10); meets the requirements as the initialised array name is boot and that the size is given by 10 during the declaration.
So the answer is OPTION 7 ( y = foo(boot,10);).
Hope this is helpful.
![1. int boot [10]; 2. int x; 3. y = foo(x); 4. y = foo(boot[5]); 5. y = foo(&x); 6. y = foo(boot); 7. y= foo(boot,10); Illustration5: Function calls Illustra 1. int boot [10]; 2. int x; 3. y = foo(x); 4. y = foo(boot[5]); 5. y = foo(&x); 6. y = foo(boot); 7. y= foo(boot,10); Illustration5: Function calls Illustra](/WebImages/1/1-int-boot-10-2-int-x-3-y-foox-4-y-fooboot5-5-y-foox-6-y-968029-1761495401-0.webp)