1. ## element ?

I have a question about the elements of A in the following:
Code:
```int Tally(float A[], int Size, float X)
{
if (Size <= 0){     /* to see if it is 0 or neg numb and returns a*/
return a;}
else
return (A[0] == X) + Tally(A + 1, Size - 1, X); /*first element is checked against X and tally a is incremented by on size decremented*/
}```

Doesnt this code return the number of elements in A equal to x

2. No you'd need something like:

return (A[0] != X) ? 0 : 1 + Tally( A + 1, Size - 1, X );

in this way, Tally always completes the recursion.

3. Does it return the number of elements in a then?

4. Originally Posted by matthughes
Does it return the number of elements in a then?
It doesn't do anything, since there is no such thing as "a"

5. Originally Posted by brewbuck
It doesn't do anything, since there is no such thing as "a"
instead of a it was supposed to be
Code:
` return 0;`

6. i got it people it returns the number of elements equal to x!!!

7. Originally Posted by citizen
No you'd need something like:

return (A[0] != X) ? 0 : 1 + Tally( A + 1, Size - 1, X );

in this way, Tally always completes the recursion.
Uh... what?

8. Originally Posted by Rashakil Fol
Uh... what?
Code:
`A[0] != X`
Is an expression it evaluates to TRUE (1) or FALSE (0).

ie, it stops recursing once A[0] is not equal to X, otherwise it continues to recurse.