Problem Solving with C++ (9th Edition)
Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 9, Problem 3P

Palindrome testing with pointers

This Practice Program requires that you read the optional section about pointer arithmetic. Complete the function isPalindrome so that it returns true if the string cstr is a palindrome (the same backwards as forwards) and false if it is not. The function uses the cstring library.

bool isPalindrome(char* cstr)

{

char* front = cstr;

char* back = cstr + strlen(cstr)−1;

while (front < back)

{

// Complete code here

}

return true;

}

 Here is a sample main function for quick and dirty testing:

int main()

{

char s1[50] = "neveroddoreven";

char s2[50] = "not a palindrome";

cout << isPalindrome(s1) << endl; // true

cout << isPalindrome(s2) << endl; // false

return 0;

}

Blurred answer
Students have asked these similar questions
We are considering the RSA encryption scheme. The involved numbers are small, so the communication is insecure.  Alice's public key (n,public_key) is (247,7). A code breaker manages to factories  247 = 13 x 19  Determine Alice's secret key. To solve the problem, you need not use the extended Euclid algorithm, but you may assume that her private key is one of the following numbers 31,35,55,59,77,89.
Consider the following Turing Machine (TM). Does the TM halt if it begins on the empty tape? If it halts, after how many steps? Does the TM halt if it begins on a tape that contains a single letter A followed by blanks? Justify your answer.
Pllleasassseee ssiiirrrr soolveee thissssss questionnnnnnn

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Write a pseudocode statement that declares the variable total so it can hold integers. Initialize the variable ...

Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)

Why were computer programming languages invented?

Starting Out With Visual Basic (8th Edition)

What is a compiler?

Java: An Introduction to Problem Solving and Programming (8th Edition)

Explain the term cursor.

Database Concepts (8th Edition)

If the roller at 8 can sustain a maximum load of 3 kN, determine the largest magnitude of each of the three for...

INTERNATIONAL EDITION---Engineering Mechanics: Statics, 14th edition (SI unit)

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
  • Text book image
    Systems Architecture
    Computer Science
    ISBN:9781305080195
    Author:Stephen D. Burd
    Publisher:Cengage Learning
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
1.1 Arrays in Data Structure | Declaration, Initialization, Memory representation; Author: Jenny's lectures CS/IT NET&JRF;https://www.youtube.com/watch?v=AT14lCXuMKI;License: Standard YouTube License, CC-BY
Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License