Problem Solving with C++ (10th Edition)
Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
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
What is Windows Server and what is the Differences between Windows Server 2019 and the Windows Operating System that people have installed on their personal computer.
solve and show the tree on paper
I need help to resolve the following activity

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
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
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