Checkpoint 2.5.1. Passing Array Parameters.
0.0
- Incorrect.
1.0
- Incorrect.
2.0
- Correct!
- random, depending on what was in memory at location a[10] when the program was run.
- Incorrect.
Given the following code, what value would be printed?
#include <stdio.h>
void foo(float arr[], int size) {
arr[10] = 2.0;
}
int main(void) {
float a[20];
a[10] = 1.0;
foo(a, 20);
printf(ā%f\nā, a[10]);
return 0;
}
Hint.
Draw a stack diagram of what happens when foo is called
Answer.
A stack diagram is shown below: