Review Test
Scroll through the page to review your answers. The correct answer is
highlighted in
green.
Your incorrect answers (if any) are highlighted in
red.
If you'd like to take the test over again, click the reset button at the end of the test.
What is the output of the following program?
void spark(int A[]) {
printf("A[0] = %d, A[1] = %d, A[2] = %d\n", A[0], A[1], A[2]);
A[1] = 0;
}
int main() {
int A[3] = {1, 2, 3};
spark(A);
printf("A[0] = %d, A[1] = %d, A[2] = %d\n", A[0], A[1], A[2]);
return 0;
}
What is the output of the following program?
void add_10(int a, int *p) {
*p = a + 10;
}
int main() {
int x = 2, y = 6;
add_10 (x, &x) ;
printf("x = %d, y = %d\n", x, y) ;
add_10 (x, &y) ;
printf("x = %d, y = %d\n", x, y) ;
return 0;
}
Given the following array declaration and function definition
void spark(int z[]);
int x[10];
suppose that
spark() changes the value of
z[1]. Is
x[1] affected?