Question
Use C++ Implementing Recursive Functions W rite a program that uses recursive function calls to calculate and print the sum of the sequence of integers
Use C++
Implementing Recursive Functions
W
rite a program that uses recursive function calls to calculate and print the sum of the sequence
of integers between two
user
-
entered values.
The program must use recursion
to solve the
problem.
Consid
er that the user entered
: 3 5
Consider that the user entered: 1 4
3 + 4 + 5 = 12
1 + 2 + 3 + 4 = 10
#include
using namespace std;
int getSumRecursive(int, int);
int main()
{
/// TASK 1: Declare two integers i and n.
/// TASK 2: Prompt the user to enter two POSITIVE integers
/// i and n such that i is LESS THAN n.
while ( /* TASK 3: Do some basic input validation. */ )
{
/// TASK 4: Give the user more chances to provide valid input.
}
cout
cout
return 0;
}
int getSumRecursive(int i, int n)
{
/// TASK 5: Implement the recursive function here.
}
Sample Output: CAUsers jlate Source ReposExampleDebug>Example.exe Space separated, enter two positive integers (1st Example.exe Space separated, enter two positive integers (1st Example.exe Space separated, enter two positive integers (1st Example.exe Space separated, enter two positive integers (1st Example.exe Space separated, enter two positive integers (1stStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started