Question: Assignment Recursion (in C++) Part1: Palindrome detector Write a program that will test if some string is a palindrome Ask the user to enter a

Assignment Recursion (in C++)

Part1: Palindrome detector

Write a program that will test if some string is a palindrome

Ask the user to enter a string

Pass the string to a Boolean function that uses recursion to determine if something is a palindrome or not. The function should return true if the string is a palindrome and false if the string is not a palindrome.

Main displays the result ( if the string is a palindrome or not

Part 2: Compute the Greatest Common Factor

Write a program that computes the GCF (Greatest Common Factor) of two positive whole numbers entered by the user. For example the GCF of 24 and 18 is 6. The program will prompt the user for entering two positive whole numbers and will then return their GCF. The user may terminate the program by entering -1 for the first number. The program should provide a recursive function to compute GCF.

Test the above for at least 4 pairs of values.

Mathematical Calculation:

GCF of two whole numbers can be calculated mathematically via repeated division. For example, GCF of 16 and 26 can be found as below:

1. Divide 16 into 26. The remainder is 10.

2. Divide 10 (the remainder in the last step) into 16 (the divisor in the last step). The remainder is 6.

3. Divide 6 (the remainder in the last step) into 10 (the divisor in the last step). The remainder is 4.

4. Divide 4 (the remainder in the last step) into 6 (the divisor in the last step). The remainder is 2.

5. Divide 2 (the remainder in the last step) into 4 (the divisor in the last step). The remainder is 0. Hence GCF is 2.

Note: You are to provide a recursive function to implement the above algorithm.

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!