Write the definition of a function named rcopy that reads all the strings remaining to be read in standard input and displays them, one on a line with no other spacing, onto standard output IN REVERSE ORDER. So if the input was: here comes the sun the output would be sun the comes here The function must not use a loop of any kind (for, while, do-while) to accomplish its job.

Respuesta :

Answer:

//Include this header file if program is executing on //visual studio.

#include "stdafx.h";

//Include the required header file.

#include <iostream>

#include <string>

//Use the standard namespace.

using namespace std;

//Define the function rcopy.

void rcopy()

{

    //Declare a string variable to store the string.

    string s;

    //Prompt the user to input the string.

    cin >> s;

    //Check if the string entered by the user reach to

    //the next line character.

    if (cin.get() == '\n')

    {

         //Display the last word in the string.

         cout << s << " ";

         //Return from the if statement.

         return;

    }

    //Make a recursive call to the function rcopy.

    rcopy();

    //Display the remaining words in the string in

    //the reverse order.

    cout << s << " ";

}

//Start the execution of the main method.

int main()

{

    //Call the function rcopy.

    rcopy();

    //Use this system command to hold the console screen      //in visual studio.

    system("pause");

    //Return an integer value to the main function.

    return 0;

}

Explanation:

See attached images for the code and output

Ver imagen igeclement43
Ver imagen igeclement43
Ver imagen igeclement43