Find the error(s) in each of the following program segments, and explain how the error(s) can be corrected :

```
int sum(int n) { // assume n is nonnegative if (0 == n)
return 0;
else
n + sum(n - 1);
}
```


Error: The result of n + sum(n - 1) is not returned; sum returns an improper result.
Correction: Rewrite the statement in the else clause as
```
return n + sum(n - 1);
```

Computer Science & Information Technology

You might also like to view...

A text box can have ____, which allow you to view any information not currently showing in the control.

A. scroll bars B. view bars C. scroll handles D. highlight bars

Computer Science & Information Technology

What purpose does the netfilter framework serve?

What will be an ideal response?

Computer Science & Information Technology

Where in the Hyper-V Settings window for a virtual machine can you configure the ability of the virtual machine to access local resources on the host computer, such as audio, printers, and USB devices?

A. Peripheral Devices B. Enhanced Session Mode Policy C. Hardware Sharing D. Host Resource Permissions

Computer Science & Information Technology

A subquery within a subquery is called a(n) ____________________ subquery.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology