Question about arrays

Aug 30, 2014 at 10:06pm
In the code below, I'm asked what the function fo(int c[], int d[]) will do. The function below has 3 arguments however, so I'm unsure if it's a typo.

If it is not a typo, am I correct in saying it will not compile since it has only two arguments?

If it is a typo, am I correct in saying the function below will put the array c and reverse it into d? i.e. if c=1 2 3 4 5, d=5,4,3,2,1 after the function call.

1
2
3
4
5
void fo(int c[], int d[], int e){
    for(int i=0;i<e;i++){
        d[e-1-i]=c[i];
    }
}
Aug 30, 2014 at 10:43pm
How would you know when to stop if you weren't given a size?
Aug 30, 2014 at 10:50pm
The question asks what does the function fo(int c[], int d[]) do(I assume not having int e is a typo), so couldn't I say it puts the reverse of the array C into array D? Should I also say, assuming c and d are equal, and e is >0?
Aug 30, 2014 at 11:01pm
Yes it reverses the array.

Should I also say, assuming c and d are equal, and e is >0?
the former are you saying the size is the same? If so they should be. The latter yeah it would make sense that the size of the container be positive.
Topic archived. No new replies allowed.