Hello. I am a beginner in programming and wanted to know if someone can help. I have no idea what I am doing or where to even start. If anyone can help me on where to begin I would appreciate it. Here is the assignment.
What does the following program do?. Copy the sample program and compile it, then find the results. Submit a report which is more than one page length to explain how the program works and how you can improve it.
The problem is I don't even know what is wrong with the program? I understand that it adds up all the numbers but am I supposed to put in the program that it is supposed to add up the numbers?
#include <iostream>
using std::cout;
using std::endl;
int whatIsThis( int [], int ); //funtion 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;
return 0; //indicates succesful termination
} // 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