1. ## am I blind

Code:
```int Count(float A[], int Size, float X)
{
if (Size <= 0)
{
return 0;
}
else
return (A[0] == X) + count(A + 1, Size - 1, X);
}```
My book has this as an example but I am lost as to what it does and it doesnt say what it does or break it down. I am trying desperately to learn recursive functions
does it set each element in A to X
or does it return the number of elements in A

2. You already know the number of elements in A; it's given as a parameter, Size. remember that arrays don't carry their size with them in C -- you need to pass them separately, or perhaps encode the size into the array somehow (for example C-style strings, which are really arrays of characters, delimit the end of the string with an entry, the number zero). So realize that A isn't a container of any kind. It identifies a location in the vast sea of memory, a point after which a number of interesting and useful floating point values are placed (that number of values being Size, as far as this function's concerned).

Now, considering that it's named Count, it probably counts something. Considering that it gets passed a floating point number X, it probably counts the number of elements equal to X. Or maybe it counts the number of elements not equal to X! Or maybe it counts the number of elements greater than X. To figure this out of course we must look closely at the code.

If Size is zero, then our array has size zero. And we return zero. Okay. The idea that it's counting _something_ has not been ruled out.

If the size is not zero, we return, uh, the value (A[0] == X) + count(A + 1, Size - 1, X). Now realize that the == function always returns 0 or 1 -- returning 1 if the values compared are equal, 0 if not. It adds this value to the value count(A + 1, Size - 1, X).

Okay. Well, what does count(A + 1, Size - 1, X) do? It looks like it counts something in an array, starting at the memory location A + 1, of length Size - 1, involving the value X. (Well, it doesn't "do" anything, since it doesn't modify any external values or perform input or output -- it just returns a number. So the question should really be worded, "Well, what does count(A + 1, Size - 1, X) equal?")

So, it implements the following algorithm:

To count the number of values equal to X, of the 'Size' values starting at position A in memory, first ask yourself if Size is zero (or less).
If Size is zero, then
... there are zero values in the region that are equal to X. (Duh.)
If Size is not zero, then
... take the number of values equal to X, of the 'Size - 1' values starting at position 'A + 1' in memory, and add to that: 1, if the value in memory at position A[0] is equal to X, or 0, if that is not the case.

So the recursive implementation follows closely what is really a _definition_ of how many values in the array are equal to X. You'll find that recursive functions, if they don't modify anything, tend to be rewordings of a mathematical specification of the function's behavior.

3. Thank you for the thorough explanation i was getting wrapped around the == when I thought it was supposed to be = and well you have outdone yourself!

4. C is case-sensitive, Count() is different from count()

5. ya think?

6. Yes.
Some computer languages are case sensitive (Java, C++, and C), while others are case insensitive (ie not case sensitive), for example BASIC (including ...
 Make a stupid statement, get a link to google. Or something like that. [/edit]