Find the error(s) in each of the following program segments and explain how the error(s) can be corrected:
(iii) int computeProd(int n) { if (n == 0) return 0; else } n * computeProd(n – 1)
int computeProd(int n) {
if (n == 1) return 1;
return n * computeProd(n-1);
}
Comments
Leave a comment