Explanation of Solution
Recursive function for checking palindrome:
The recursive function definition for checking the given string is a palindrome or not is shown below:
/* Function definition for checkPalindromeRecursion function */
bool checkPalindromeRecursion(string str)
{
/* If length is "0" or "1", then return "true" */
if(str.length() == 0 || str.length() == 1)
return true;
/* Check the first character*/
if(isdigit(str.at(0)))
{
/* If the first character is equal to the last character, then */
if(str.at(0) == str.at(str.length()-1))
/* Recursively call the function "checkPalindromeRecursion" with remaining characters */
return checkPalindromeRecursion(str.substr(1, str.length()-2));
}
//Otherwise
else
{
//For checking the lower characters
if(tolower(str.at(0)) == tolower(str.at(str.length()-1)))
return checkPalindromeRecursion(str.substr(1, str.length()-2));
}
//Otherwise returns "false"
return false;
}
Explanation:
The above function is used to check the given string is a palindrome or not using recursive function.
- If the length of string is “0” or “1”, then returns “true”.
- Check the first digit of given string. If it is, then check if the first character is equal to the last character, then recursively call the function “checkPalindromeRecursion” for remaining characters in given string.
- Otherwise, return “false” that is for not palindrome string.
Complete Executable code:
The complete code is implemented for checking the palindrome is shown below:
//Header file
#include <iostream>
#include <iomanip>
//For standard input and output
using namespace std;
/* Function definition for checkPalindromeRecursion function */
bool checkPalindromeRecursion(string str)
{
/* If length is "0" or "1", then return "true" */
if(str...
Want to see the full answer?
Check out a sample textbook solutionChapter 14 Solutions
Problem Solving with C++ (10th Edition)
- Scenario You work for a small company that exports artisan chocolate. Although you measure your products in kilograms, you often get orders in both pounds and ounces. You have decided that rather than have to look up conversions all the time, you could use Python code to take inputs to make conversions between the different units of measurement. You will write three blocks of code. The first will convert kilograms to pounds and ounces. The second will convert pounds to kilograms and ounces. The third will convert ounces to kilograms and pounds. The conversions are as follows: 1 kilogram = 35.274 ounces 1 kilogram = 2.20462 pounds 1 pound = 0.453592 kilograms 1 pound = 16 ounces 1 ounce = 0.0283 kilograms 1 ounce = 0.0625 pounds For the purposes of this activity the template for a function has been provided. You have not yet covered functions in the course, but they are a way of reusing code. Like a Python script, a function can have zero or more parameters. In the code window you…arrow_forwardmake a screen capture showing the StegExpose resultsarrow_forwardWhich of the following is not one of the recommended criteria for strategic objectives? Multiple Choice a) realistic b) appropriate c) sustainable d) measurablearrow_forward
- Management innovations such as total quality, benchmarking, and business process reengineering always lead to sustainable competitive advantage because everyone else is doing them. a) True b) Falsearrow_forwardVision statements are more specific than strategic objectives. a) True b) Falsearrow_forwardThe three components of the __________ approach to corporate accounting include financial, environmental, and social performance measures. Multiple Choice a) stakeholder b) triple dimension c) triple bottom line d) triple efficiencyarrow_forward
- Competitors, as internal stakeholders, should be included in the stakeholder management consideration of a company and in its mission statement. a) True b) Falsearrow_forwardAt what level in the organization should the strategic management perspective be emphasized? Multiple Choice a) throughout the organization b) from the bottom up in an organization c) at the top of the organization d) at the middle of the organizationarrow_forwardA good manager can be flexible when it comes to sticking to the original plan; to get good results, the intended strategy has to become the realized strategy. a) True b) Falsearrow_forward
- ________ tend to be quite enduring and seldom change. Multiple Choice a) Strategic objectives b) Vision statements c) Strategic plans d) Mission statementsarrow_forwardThe idea that organizations are not only accountable to stockholders but also to the community-at-large is known as social responsibility. a) True b) Falsearrow_forwardAmong the leaders needed for an effective strategic management process are ________, who, although they have little positional power and formal authority, generate their power through the conviction and clarity of their ideas. Multiple Choice a) executive leaders b) triple bottom line advocates c) internal networkers d) local line leadersarrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- Systems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage LearningCOMPREHENSIVE MICROSOFT OFFICE 365 EXCEComputer ScienceISBN:9780357392676Author:FREUND, StevenPublisher:CENGAGE L