Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program which asks the user to enter a string and then passes it to a vo

ID: 3761143 • Letter: W

Question

Write a program which asks the user to enter a string and then passes it to a void recursive function which displays the string in reverse. The prototype of the function would be:void reverse(string s, int i); The call would be:reverse(strIn, strIn.length()); A typical run will be: Enter a stringFour score and seven years ago .. .. oga sraey neves dna erocs ruoF
WRITTEN IN C++ Write a program which asks the user to enter a string and then passes it to a void recursive function which displays the string in reverse. The prototype of the function would be:void reverse(string s, int i); The call would be:reverse(strIn, strIn.length()); A typical run will be: Enter a stringFour score and seven years ago .. .. oga sraey neves dna erocs ruoF
WRITTEN IN C++ Write a program which asks the user to enter a string and then passes it to a void recursive function which displays the string in reverse. The prototype of the function would be:void reverse(string s, int i); The call would be:reverse(strIn, strIn.length()); A typical run will be: Enter a stringFour score and seven years ago .. .. oga sraey neves dna erocs ruoF
WRITTEN IN C++ Write a program which asks the user to enter a string and then passes it to a void recursive function which displays the string in reverse. The prototype of the function would be:void reverse(string s, int i); The call would be:reverse(strIn, strIn.length()); A typical run will be: Enter a stringFour score and seven years ago .. .. oga sraey neves dna erocs ruoF
WRITTEN IN C++

Explanation / Answer

#include <iostream>

#include<string.h>

using namespace std;

void reverse(string s, int i)

{

if(i>=0)

{

cout << s[i];

reverse(s, i-1);

}

}

int main()

{

string s = "stringFour score and seven years ago";

reverse(s,s.length()-1);

return 0;

}

OP:

oga sraey neves dna erocs ruoFgnirts

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote