Solution to STRING REVERSE PROGRAM Create a program that will apply recursive functions. The program should accept … - Sikademy
Author Image

Archangel Macsika

STRING REVERSE PROGRAM Create a program that will apply recursive functions. The program should accept a string say SUBJECT. The output of the program should be TCEJBUS . Screen/Layout Input a string: SUBJECT After a reverse: TCEJBUS Try Another[Y/N]: Y Input a string: face After reverse: ecaf Try Another[Y/N]:N

The Answer to the Question
is below this banner.

Can't find a solution anywhere?

NEED A FAST ANSWER TO ANY QUESTION OR ASSIGNMENT?

Get the Answers Now!

You will get a detailed answer to your question or assignment in the shortest time possible.

Here's the Solution to this Question


using namespace std; /* STRING REVERSE PROGRAM Create a program that will apply recursive functions. The program should accept a string say SUBJECT. The output of the program should be TCEJBUS . Screen/Layout Input a string: SUBJECT After a reverse: TCEJBUS Try Another[Y/N]: Y Input a string: face After reverse: ecaf Try Another[Y/N]:N */ void ReverseString(string &u, int k) {     static int i = 0;     if (k == u.length()) return;     ReverseString(u, k + 1);     if (i <= k) swap(u[i++], u[k]); } int main() { string s; char c = 'y'; int Flag=1; while(Flag) { cout<<"\n\nInput a string: "; cin>>s; ReverseString(s,0); cout<<"\nAfter Reverse: "<<s; cout<<"\n\nTry another (Y/N): "; cin>>c; if(c=='y'||c=='Y') Flag=1; else Flag=0; } return(0); }

Related Answers

Was this answer helpful?

Join our Community to stay in the know

Get updates for similar and other helpful Answers

Question ID: mtid-3-stid-44-sqid-1015-qpid-12