Palindrome testing with pointers
This Practice
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; } |
Want to see the full answer?
Check out a sample textbook solutionChapter 9 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
C Programming Language
Starting Out with C++ from Control Structures to Objects (9th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
C How to Program (8th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
- C++ code NB: Pointers must be usedarrow_forwardShared pointers keep a count of all of the shared pointers that appear in the program code. True Falsearrow_forwardC++ Coding: ArraysTrue and False Code function definitions for eoNum() and output(): Both eoNum() and output() are recursive functions. output() stores the even/odd value in an array. Store 0 if the element in the data array is even and store 1 if the element in the data array is odd. eoNum() displays all the values in an array to the console.arrow_forward
- In C++ I need to compose a function that accepts an array of integer values as an argument and returns the total of the values in the arrayarrow_forwardC programming pseudocode pointers help. { totalInAGivenHour+=*(rawReadings+ monthNo*30*14*4 + 14*4*nThDateOfMonth+ 4*nThHourOfDateFrom7AM + nThReadingTimeOfHour); // the pointer is to assign the values in the bracket and storing them in totalInAGivenHour }arrow_forwardTo receive an array argument, a function's parameter list must specify that the function expects to receive an array. The size of the array is not required between the array brackets. Select one: True O Falsearrow_forward
- In C programming language Question (Strings) Write a function find_Substring() that finds a substring into a string. Pass array s1 and s2 to this function and prints if the substring is present or not. Expected Output 1: Enter string This is a javascript Enter substring script The substring is present Expected Output 2: Enter string This is a javascript Enter substring Jscript The substring is not presentarrow_forwardin c++arrow_forwardC++ Array Expander -Just do everything in main and make sure you comment each step Use Pointer Notation for the function and within the function. Use a main function and return the pointer from the ArrayExpander function to mainarrow_forward
- Topic: pointers, dynamic array and command line arguments Write a complete C++ program named “showHelp” that accepts command line arguments. It checks whether there is a command line argument of “/help” or“/?” or “-help” followed by a topic number. It will print out “yes, topic number(<number>) if there is one. Otherwise, it prints out “no, topic number(N/A) For example, if you run this program with correct arguments as follows, it willprint out yes and its associated topic number respectivelyshowHelp /? 101showHelp /debug /help 102showHelp /print /help 103 /verboseshowHelp -verbose -debug -help And if you run the program with invalid arguments, it will print no, in all casesshowHelp -helpshowHelp 101 /?showHelp 101 102 /help /verboseshowHelp /? /help -helpNote: command line arguments are simply an array of pointers to C-string. example code: #include <iostream> using namespace std; int main(int argc, char** argv){...}arrow_forwardProgramming language C++ NB :Make use of pointers to solve the following programarrow_forwardc++problemarrow_forward
- Systems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage Learning