Write a recursive function that reads a list of integers until a negative value is encountered and returns the sum of the nonnegatives read. The function may assume that the input is a valid list of integers containing at least one negative value.

What will be an ideal response?

```
int sumList ()
{
int num, ans;
cout << "Enter any number - negative to stop" << endl;
cin >> num; if (num < 0) ans = 0;
else

ans = num + sumList ();
return ans;
}
```

Computer Science & Information Technology

You might also like to view...

A broadband connection can refer to either DSL or cable Internet access

Indicate whether the statement is true or false

Computer Science & Information Technology

Only controls capable of receiving some sort of input, such as _________________, may have the focus.

a. labels b. text boxes c. buttons d. text boxes and buttons

Computer Science & Information Technology