/Recursive-Array-Addition

Program that first prompts the user to enter a value between 1 and 10. The program then uses this integer as a parameter to a recursive function that computes the sum of the N integers in the array. (C++)

Primary LanguageC++

Recursive Array Addition

Data Structures/Concepts Used:

Array, Recursive Addition

Description:

Write a computer program that sums the first N elements of the following array using a recursive function. Your program must first prompt the user to enter a value between 1 and 10. Then your program must use this integer as a parameter to a recursive function that computes the sum of the N integers in the array. Finally, your program must display the results. int myarray[10] = {23, 45, 12, 67, 34, 90, 1, 75, 3, 6};

Output:

This program sums up the first N elements of an array (N<=10).
Array = [23, 45, 12, 67, 34, 90, 1, 75, 3, 6]

Enter an integer between  1 and 10: 25
Error. Integer is out of range.

Enter an integer between  1 and 10: -1
Error. Integer is out of range.

Enter an integer between  1 and 10: 5

Total of first 5 elements: 181


() Code by Tacuma Solomon
() Not for Redistribution or Reuse.

Press any key to continue . . . .