Question: C + + PDF code: * / #include using namespace std; / * * Displays the reverse of a non blank string s . @
PDF code:
#include
using namespace std;
Displays the reverse of a non blank string s
@ pre s should not be blank.
@ post The reverse of the string s is dispalyed.
void displayBackwardsstring;
int main
string s;
cout Enter a string ;
cins;
cout"Reverse of string s ;
displayBackwardss;
return ;
Displays the reverse of a non blank string s
@ pre s should not be blank.
@ post The reverse of the string s is dispalyed.
void displayBackwardsstring s
int length ssize;
iflengthbase case
couts,s and then calls ReverseString on
minus the last character. Notice that it doesn't work anymore! It no longer reverses the string. Look at what it does and
think about why.
What further changes can you make to the function to fix it In other words, write a recursive function that reverses the
string, but you aren't allowed to print out the last character in s You are allowed print out the first character in s Useful
string functions:
ssize returns length of string s
ssubstrposlen returns the substring of of length len starting at postion pos zero is first position
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
