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...
Answer the following statements true (T) or false (F)
1) A view is created with WITH CHECK OPTION to prevent modifications to all columns used in the view. 2) CURRVAL returns the START WITH value of a sequence for a sequence that is created but never used to generate a value. 3) When a view is dropped, the underlying table is also dropped. 4) When a table is dropped, the sequence used on that table also gets dropped.
Which of the following sets of statements will set floating point output to the stream outStream to fixed point with set 3 places of decimals? In the explanation, you must give any necessary #include directives and using directives or declarations.
a) ``` outStream.setf(ios::fixed); outStream.setf(ios::showpoint); outStream.precision(2); ``` b) ``` outStream.setf(ios::fixed | ios::showpoint); outStream << setprecision(2); ``` c) ``` outStream << setflag(ios::fixed); outStream << setflag(ios::showpoint); outStream << setprecision(2); ``` d) ``` outStream.flags(ios::fixed); outStream.flags(ios::showpoint); outStream.precision(2); ```