Questions about Recursion?

maxall exercise (tail recursive case)

maxall exercise (tail recursive case)

par Adam AlBazzal,
Nombre de réponses : 2
Avatar GroupEn

can we consider this code as a solution:

'''c

int maxall( int T[] , int size ,int m )

{

if(size==1)

{

if(m>T[0])

     return m;

return T[0];

}

return maxall(T+1,size-1,m);

}

note:i called the function maxall in the main like this:

max=maxall(anarray,15,anarray[0]);

}

En réponse à Adam AlBazzal

Re: maxall exercise (tail recursive case)

par Adam AlBazzal,
Avatar GroupEn

Sorry this is the correct code

```c

int maxall( int T[] , int size ,int m )

{

if(size==1)

{

if(m>T[0])

     return m;

return T[0];

}

m=max2(T[1],m);

return maxall(T+1,size-1,m);

}

note:i called the function maxall in the main like this:

max=maxall(anarray,15,anarray[0]);

```c