Implement a function to recursively

Assignment Help C/C++ Programming
Reference no: EM13163468

Half of the code is done. It's shown below, please follow as its starting and provide a simplicity code.   

Palindrome Tester (C++)

Implement a function to recursively determine if a word is a palindrome. A palindrome is a word, phrase, number, or other sequence of symbols or elements, whose meaning may be interpreted the same way in either forward or reverse direction. Famous examples include "Able was I ere I saw Elba", "A man, a plan, a canal: Panama".

Important questions to ask yourself:

  • What is the base case?
  • What is the recursive case?

The substr method of the string class will be useful. It takes the starting position of the first character to be copied as a substring and the number of characters to include in the substring.
Also useful is the length method. It returns the length of the string in question.

Examples:

string s = "defiant";
cout << s.substr(2, s.length()-4) << endl;

The above example prints out: fia

Here is some code to get you started. Submit your modified palindrome function. Do not modify the main function. When testing your function don't forget to type the word on the command line after "a.out": ./a.out radar
Starting...

#include <iostream>
#include <string>

using std::cout;
using std::endl;
using std::string;

bool palindrome(string);

int main(int argc, char *argv[]) {

    string s = argc == 2 ? argv[1] : "redivider";

    if (palindrome(s)) {
        cout << "\"" << s << "\" is a palindrome." << endl;
    }
    else {
        cout << "\"" << s << "\" is not a palindrome." << endl;
    }

    return 0;
}

bool palindrome(string w) {

    // your code goes here

    return false;
}

Reference no: EM13163468

Questions Cloud

Display the array, the average and the number of days above : Write a program that stores the daily temperatures for the month of April in an array name dailytemp. Calculate the average temperature for the month and the count the number of days that the daily temperature was above the average.
Simple java application that uses the string : Create a simple Java application that uses the String class and/or the StringBuffer class and at least 4 of the class methods. Show the code, demonstrate it works properly and describe what it is doing.
Using unix extract the various ethnic populations in file : Using Unix extract the various ethnic populations in your file.
Using array subscript notation : Using array subscript notation, base/offset notation with the array name as the pointer, array notation with  vPtr , and pointer/offset notation with  vPtr , add 3 to the value in the 3 rd element and display that number. (Do not modify the value in ..
Implement a function to recursively : Implement a function to recursively determine if a word is a palindrome. A palindrome is a word, phrase, number, or other sequence of symbols or elements, whose meaning may be interpreted the same way in either forward or reverse direction.
. assume the node is in the usual info-link form with info : Show what is produced by the following C++ code. Assume the node is in the usual info-link form with the info of the type int. (list, trail, and current are pointers of type nodeType.)
Prepare the journal entry to record depreciation expense : Irons Delivery, Inc., purchased a new delivery truck for $42,000 on January 1, 2009. The truck is expected to have a $2,000 residual value at the end of its five-year useful life. Irons uses the straight-line method of depreciation.
Compute price and usage variances for direct materials : Compute price and usage variances for direct materials and compute the direct labor rate and labor efficiency variances.
Find all irreducible polynomials : Find all irreducible polynomials1. of degree 3 over GF(2),2. of degree 4 over GF(2).

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd