What does the following program do?

```
// What does this program do?
#include
using namespace std;

int whatIsThis( int [], int ); // function prototype

int main()
{
const int arraySize = 10;
int a[ arraySize ] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

int result = whatIsThis( a, arraySize );

cout << "Result is " << result << endl;
} // end main

// What does this function do?
int whatIsThis( int b[], int size )
{
if ( size == 1 ) // base case
return b[ 0 ];
else // recursive step
return b[ size - 1 ] + whatIsThis( b, size - 1 );
} // end function whatIsThis
```


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

Computer Science & Information Technology

You might also like to view...

Is it possible to have an array of C-strings? Is so, give an example of the declaration.

What will be an ideal response?

Computer Science & Information Technology

Formatting the values and overall appearance of a PivotTable is done by opening this dialog box for the field:

A) Formula. B) Format. C) Properties. D) Captions.

Computer Science & Information Technology

What Windows components are kept in the WOW6432NODE folder?

A) 32-bit registry keys B) 32- and 64-bit device drivers C) 32- and 64-bit Windows file D) 32- and 64-bit Windows networking commands

Computer Science & Information Technology

Which command can be used to create a new command that will monitor the contents of auth.log as they get added to the file? 

A. create showauth=’tail -f /var/log/auth.log’ B. alias showauth=’tail -f /var/log/auth.log’ C. new showauth as ‘cat -f /var/log/auth.log’ D. ln showauth=’tail -f /var/log/auth.log’

Computer Science & Information Technology