Thursday, July 30, 2009

What is the error in the following recursion function?

void Fill_Ary(int A [ ], int N)


{





if (N ! =0)





{


--N;


A [N} =N;





Fill_Ary (A,N);


}





}








a. It will always result in an infinite recursion loop


b. It will cause an infinite recursion loop for some values of N but not for others


c. There is a syntax error in the function


d. there is no error in the function

What is the error in the following recursion function?
C. " A [ N } " is not a proper variable array.
Reply:It won't be an infinite loop, but if N is a negative value then the function won't end until N exceeds the lowest value for an int and becomes positive and then reaches zero. I would tend to think that would be a problem.


No comments:

Post a Comment