so i am given this code...
insert
Code:
#include <stdio.h>
void function1(int array[], int length);
int main() {
int values[] = {2, 5, 1, 0, 3, 4};
function1(values, 6);
return 0;
}
void function1(int array[], int length) {
int temp[length], i;
for (i=0; i<length; i++)
temp[i] = array[array[i]];
for (i=0; i<length; i++)
array[i] = temp[i];
for (i=0; i<length; i++)
printf("%d ", array[i]);
}
and i have to answer this question...
1) Let the array values be an integer array of size 6 storing the following values (in this order): 2, 5, 1, 0, 3, 4. What is the output of running the function call function1(values, 6)?
A) 2 5 1 0 3 4
B) 0 1 2 3 4 5
C) 5 4 3 2 1 0
D) 1 4 5 2 0 3
E)NOTA
The answer is D can anyone explain why? i just dont get it...