Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement programming problems 6 and 12 below at the end of chapter 15. You should implement the two problems as two functions and use one

Implement programming problems 6 and 12 below at the end of chapter 15.

You should implement the two problems as two functions and use one

main program. Your main program should use a look with the following

interface (see blow). choosing 1 prompts the user to enter a string for the

Palindrome function. Choosing 2 prompts the user to enter x and y values

and runs GCD. Choosing 3 quits the loop and the program.

choose A Program:

1- Run the Palindrome

2- Run the GCD

3- Quit

Problem 6:

A palindrome is a string that reads the same both forward and backward.

For example, the string "madam" is a palindrome. Write a program that uses a

recursive function to check whether a string is a palindrome. Your program must contain

a value-returining recursive function that return true if the string is a palindrome and false

otherwise. Do not use any global variables; use the appropriate parameters.

Problem12:

(Greatest Common Divisor) Given two integers x and y, the following recursive

definition determines the greatest common divisor of x and y, written gcd(x,y):

gcd(x,y) = {x if y = 0

{gcd(y, x%y)if y /= 0

Note: in this definition function, gcd, that takes as parameter, two integers and returns the

greatest common divisor of the numbers. Also, write a program to test your function.

Note: You should implement the two problems as two functions and use one

main program. Your main program should use a look with the following

interface (see blow). choosing 1 prompts the user to enter a string for the

Palindrome function. Choosing 2 prompts the user to enter x and y values

and runs GCD. Choosing 3 quits the loop and the program.

choose A Program:

1- Run the Palindrome

2- Run the GCD

3- Quit

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions