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

This needs to be done in C++. I have inlcuded the test run and image error as we

ID: 3915147 • Letter: T

Question

This needs to be done in C++. I have inlcuded the test run and image error as well as my current code.

//header file section

#include <iostream>

using namespace std;

//function prototype

void Reverser(char[], int, int);

//main function

int main()

{

char names[20];

cout << " Enter string: ";

gets_s(names);

int len = strlen(names);

//function call

Reverser(names, 0, len - 1);

system("pause");

return 0;

}//end main

//function defenition

void Reverser(char array[], int pos, int size)

{

if (pos <= size)

{

cout << array[size];

Reverser(array, pos, size - 1);

}

}

Explanation / Answer

c++ code :


//header file section
#include <iostream>
using namespace std;
//function prototype
void Reverser(string array, int pos, int size);
//main function
int main()
{
string names; // declaring a string
cout << " Enter string: ";
cin >> names; // taking input
int len = names.length(); // computing the length of the string
//function call
Reverser(names, 0, len - 1);
return 0;
} //end main
//function defenition
void Reverser(string array, int pos, int size)
{
if (pos <= size)
{
cout << array[size]; // printing the output
Reverser(array, pos, size - 1);
}
}

Output :

Enter string: I_am_he_as_you_are
era_uoy_sa_eh_ma_I

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