Here is a recursive function that is supposed to return the factorial. Identify the line(s) with the logical error(s). Hint: This compiles and runs, and it computes something. What is it?
```
int fact( int n ) //a
{
int f = 1; //b
if ( 0 == n || 1 == n ) //c
return f; //d
else
{
f = fact(n - 1); //f
f = (n-1) * f; //g
return f; //h
}
}
```
The function computes (n-1)! The logical error is in line g) which should be f = n * f; rather than
You might also like to view...
A computer must have a DVD drive in order to install Windows 8.
Answer the following statement true (T) or false (F)
____ protects the entire layer or the page items on a layer from being moved, selected, or deleted accidentally.
A. Hiding B. Locking C. Protecting D. Sealing
Microsoft _____ is the word-processing program in the Microsoft Office suite.
Fill in the blank(s) with the appropriate word(s).
During an interview for a help desk position, directed questions are open-ended and give an applicant an opportunity to talk in general terms compared with non-directed questions.
Answer the following statement true (T) or false (F)