What does the following program do?

```
// Ex07_17.cpp
// What does this program do?
#include
#include
using namespace std;
const size_t arraySize{10};
int whatIsThis(const array&, size_t); // prototype
int main() {
array a{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int result{whatIsThis(a, arraySize)};

cout << "Result is " << result << endl;
}
// What does this function do?
int whatIsThis(const array& b, size_t size) {
if (size == 1) { // base case
return b[0];
}
else { // recursive step
return b[size - 1] + whatIsThis(b, size - 1);
}
}
```


This program sums array elements. The output would be
Result is 55

Computer Science & Information Technology

You might also like to view...

When an End Sub statement is reached in a Sub procedure, execution jumps to

(A) the statement before the statement that called the Sub procedure. (B) the statement after the statement that called the Sub procedure. (C) the beginning of the event procedure containing the calling statement. (D) the end of the event procedure containing the calling statement.

Computer Science & Information Technology

Let F be an algorithm with complexity function f(n), and let G be an algorithm with complexity function g(n). If the ratio f(n)/g(n) converges to 2 as n increases to infinity, then

A) the two algorithms are equivalent in efficiency and there is no clear winner B) implementations of F will require twice as much time as implementations of G C) we can deduce that F runs in linear time while G runs in quadratic time D) implementations of F will require twice as much space as implementations of G

Computer Science & Information Technology

When you call ls with an argument (a word following ls and separated from ls by a SPACE), ls displays the name of the file named by the argument or dis- plays an error message if the file does not exist. Call ls with the name of the file created in step 1 and the string xxxx (you must separate each argument from the next by a SPACE). What happens?

What will be an ideal response?

Computer Science & Information Technology

____ refers to a new use of existing technologies.

A. XML B. PHP C. AJAX D. JavaScript

Computer Science & Information Technology