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++ (9th 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)
- Submarining is a phenomenon that occurs when the pointer disappears when you move it too rapidly.arrow_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
- When you move the pointer too quickly, a phenomena known as submarineing happens when the cursor vanishes.arrow_forwardint *p; where p is a null pointer when:arrow_forwardIn c++, please and thank you! Write a function that dynamically allocates an array of integers. The function should accept an integer argument indicating the number of elements to allocate. The function should return a pointer to the array.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_forwardIn 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_forward
- Median Function – In statistics, the median of a set of values is the value that lies in the middle when the values are arranged in sorted order. If the set has an even number of values, the median is the average of the two middle values. Your program should start with two arrays of integers containing the following values: Even numbered array: 17 32 45 68 99 101 67 89 22 27 Odd numbered array: 17 32 45 68 99 101 67 89 22 Using a sort function of your choice, first sort the arrays. NOTE: you may use the Standard Template Library sort function or your own sort function. Then, write a function that determines the median of a sorted array. The function should take an array of numbers and an integer indicating the size of the array and return the median of the values in the array. The same function should be called twice – once for the even array and once for the odd array. Your program should also have a printArray function that can be used to print the sorted array. (It…arrow_forwardIn 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_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 Falsearrow_forward
- Systems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage Learning