English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

void Mystery(int A[ ], int size)
{
if (size > 0) {A[0] =0; Mystery (A+1, size -1);}
}

a. It sets the first element of the array A to zero

b. It sets the last element of the array A to zero

c. It sets the all elements of the array A to zero

d. It generates an infinite recursion loop

2006-09-03 12:40:00 · 2 answers · asked by Anonymous in Computers & Internet Programming & Design

2 answers

Hi,

There are two possible outcomes. If this was asked by a undergrad professor, it is most likely C.

Each iteration, you setting the first element to 0, and then calling the the function after you move the array pointer to the next meroy address.

If you are asked this by a tricky professor or in an advanced class, there is a second, more subtle answer. Which is that nothing will happen. This will happen any time a non-positve number is passed as the variable size.

I doubt the second answer is what your professor is looking for, but these types of questions were pretty common in some advanced graduate classes so I wanted to point it out, just in case.

Cheers,

Leo

2006-09-03 19:26:49 · answer #1 · answered by Leo R 2 · 0 0

The answer is a, and it does it 'size' times.

2006-09-03 22:20:12 · answer #2 · answered by sterno73 3 · 0 0

fedest.com, questions and answers