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 4PP

Write a function that takes a C string as an input parameter and reverses the string. The function should use two pointers, front and rear. The front pointer should initially reference the first character in the string, and the rear pointer should initially reference the last character in the string. Reverse the string by swapping the characters referenced by front and rear, then increment front to point to the next character and decrement rear to point to the preceding character, and so on, until the entire string is reversed. Write a main program to test your function on various strings of both even and odd length.

Blurred answer
Students have asked these similar questions
A palindrome is a string that reads the same in its reverse. For example maam, wow, racecar, madam etc. Write a function in C++ named palindrome. The function will take a character array as input and will return 1 if the string is a palindrome and 0 otherwise.
Write a user-defined function that compares two string with each other. If first one is equal to second returns 0, greater than second returns 1 and less than second returns -1. Your function prototype is int compareString(char *, char *) Write another user-defined function which gets a pointer to a character string containing the name of months. Function will return the name of month depending on its arguments. For example : if it gets 2 it will return February. if it gets O it will return incorrect month if it gets 9 it will return September Your function prototype is char "month_name(int n) Write a main function to test your functions. Do not use library functions to compare two strings. Example Input: Ankara Antalya 4 Example Output: -1 April
Write a function which will take 2 arguments. They are: • Sentence • position Your first task is to take these arguments as user input and pass these values to the function parameters. Your second task is to implement the function and remove the characters at the index number which is divisible by the position (Avoid the index number 0 as it will always be divisible by the position, so no need to remove the index 0 character). Finally, add the removed characters at the end of the new string. Return the value and then finally, print the new string at the function call. Input: "I love programming." 3 Function call: function_name("I love programming.", 3) Output: I lveprgrmmngo oai. Input: "Python is easy to learn. I love python." 6 Function call: function_name("Python is easy to learn. I love python.", 6) Output: Pythonis eay to earn.l lov pythn. sl eo

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
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
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
What Are Data Types?; Author: Jabrils;https://www.youtube.com/watch?v=A37-3lflh8I;License: Standard YouTube License, CC-BY
Data Types; Author: CS50;https://www.youtube.com/watch?v=Fc9htmvVZ9U;License: Standard Youtube License