Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

In this assignment, we want to test our knowledge on recursion and use it to solve two problems. 1- Symmetric Strings A number is said to be symmetric if it is read the same in both forward and...

1 answer below »
In this assignment, we want to test our knowledge on recursion and use it to solve two problems.

1- Symmetric Strings A number is said to be symmetric if it is read the same in both forward and backward ways. Write a recursive program to check if a given number is symmetric. Your program should print either Symmetric or Asymmetric as its output. See some examples below:
Input: XXXXXXXXXX XXXXXXXXXX
Output: Symmetric Symmetric Asymmetric Symmetric
You should get the input number from user.

2- Ladder Someone wants to go up a ladder. Each time, they have the option to either go to the next rung or skip the next rung and go to the next next rung. So, either one rung at a time or two rungs at a time. Write a recursive program that computes the number of possible ways that a person can move up the ladder. You should get number of rungs of the ladder from the user.
Answered Same Day Jul 01, 2021

Solution

Aditya answered on Jul 02 2021
162 Votes
#include using namespace std;
int repeat(int n)
{
if(n<=1)
return n;
return repeat(n-1)+repeat(n-2);
}
int ways(int temp)
{
return repeat(temp+1);
}
int main()
{
int number;
cout
"Enter number of rugs: ";
cin
number;
cout
"Number of...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here