This is the code that I wrote for Problem # 5. Seems to be working. You will have to figure out the logic behind this code :)
#include <iostream>
#include <string>
using namespace std;
int calculateSum(int arr[], int index);
void main()
{
int arr[10] = {1,1,1,1,1,1,1,1,1,1};
for(int i = 1; i < 15; i++)
{
int total_sum = 0;
for(int j = 0; j < 10; j++)
{
int sub_sum = calculateSum(arr, j);
//cout << sub_sum << endl;
total_sum = total_sum + sub_sum;
arr[j] = sub_sum;
}
//cout << "===================================" << endl;
cout << "For " << i+1 << " digit number, the answer is: " << total_sum << endl;
}
}
int calculateSum(int arr[], int index)
{
int sum = 0;
for(int i = index; i < 10; i++)
{
sum = sum + arr[i];
}
return sum;
}