Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

basic recursion is a technique that, for many, takes time and practice to master

ID: 3691626 • Letter: B

Question

basic recursion is a technique that, for many, takes time and practice to master. In this program, you are to create a menu-driven program that allows the user to execute one of several recursive routines as many times as desired. The menu must fast the routines, accept the user's selection, and then perform the chosen recursive routine. The menu must also list an option to quit the program. Use a character to accept the menu choice and error trap for tad menu selections. Also print welcoming and goodbye messages at the start/end of the program. Given an integer array of sue 100 (Filed with numbers read in from a file called "numbeis.txt", which is assumed to have 100 integer values), do the following: display the array to the screen (use loops if you want and print 10 rows of 10 numbers each), ask the user how many numbers they would like totaled (error trap accepting only numbers between 1 and 100), Traverse the array recursively starting at the first element in the array and display each element in the array up to the number the user entered, and display the total of all the elements traversed Ask the user to enter a non-negative integer (error trap for bad input) Then display the number with the digits reversed For example, if the user entered 3456, the reversed number should be 6543 3. Implement Euclid's Algorithm, described below. Euclid s Algorithm: In t void's Elements (Book VII) we find a way of calculating the GCD of two numbers, without listing the divisors of either number. It is now called Euclid's Algorithm First an example; Find the GCD of 36 and 15. Divide 36 by 15 (the greater by the smaller), getting 2 with a remainder of 6. Then we divide 15 by 6 (the previous remainder) and we get 2 and a remainder of 3. Then we divide 6 by 3 (the previous remainder! and we get 2 with no remainder The test non zero remainder (3) Is our GCD. Here it is in general: a/b gives a remainder of r b/r gives a remainder of s r/s gives a remainder of t w/x gives a remainder of y x/y gives no remainder In this case, y is the GCD of a and b. If the fest step produced no remainder, then b (the tester of the two numbers) Is the GCD. Write a recursive function that draws a rectangle to the screen. Ask the user to enter positive integers for the height and width of the rectangle (error trap tor bad input) Than au the user for a character to use to print the rectangle (no error trap required). Than print the rectangle to the screen. No loops are allowed when printing the rectangle.

Explanation / Answer

Comments added ... Done first part only.. as you asked to solve first part only...

#include <iostream>
#include <fstream>
#include <sstream>

using namespace std;

int ArrayTotaler(int array[100], int lastIndex){
if(lastIndex == 0){
return array[lastIndex];
}
return array[lastIndex] + ArrayTotaler(array, lastIndex-1);
}
int main()
{
std::ifstream readfile("file.txt");//reding numbers from text file
std::string eachline;
int count=0, arr[100];
while (std::getline(readfile, eachline))
{
std::istringstream iss(eachline);
int n;
while (iss >> n)//reading each value from file
{
arr[count] = n;
count++;
}
}
  
//printing numbers from file
for(int i=0;i<count;i++){
cout<<arr[count]<<" ";
if(i%10 == 0){
cout<<" ";
}
}
  
//getting total calling recursive method
cout<<"Upto how many numbers you want to get total: ";
int num;
cin>>num;
cout<<"Total: "<<ArrayTotaler(arr,num);
return 0;
}