Question: In C++ code, write a program with the following two functions. Both functions must be RECURSIVE FUNCTIONS and HAVE COMMENTS explaining what each part of

In C++ code, write a program with the following two functions. Both functions must be RECURSIVE FUNCTIONS and HAVE COMMENTS explaining what each part of the program is doing. The program should match the program run screen below.

Recursive function 1:

int sum(int n);

// Recursive version to calculate the sum of

// 1+2+....+n

Recursive function 2:

int str_length(char s[]); // Recursive version of strlen in C strings. // It returns the length of the string s[]. // (the null character, '\0', is not counted in the length)

Program run screen:

Enter a positive integer: 10

The sum of 1+2+...+10 is: 55

Enter a sentence: Hello World!

It contains 12 chars, including white spaces

Do you want to have another run? Y/N: y

Enter a positive integer: 100

The sum of 1+2+...+100 is: 5050

Enter a sentence: I love programming!

It contains 19 chars, including white spaces

Do you want to have another run? Y/N: n

Program ended with exit code: 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!