< previous page page_1151 next page >

Page 1151
10. Given the following input data (where \n denotes the newline character):
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
ABCDE\n
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
what is the output of the following program?
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
#include <iostream.h>

void Rev();

int main()
{
    Rev();
    cout < endl;
    return 0;
}

//***************************************

void Rev()
{
    char ch;

    cin.get(ch);
    if (ch != '\n')
    {
        Rev();
        cout << ch;
    }
}
11. Repeat Exercise 10, replacing the Rev function with the following version:
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
void Rev()
{
    char ch;

    cin.get(ch);
    if (ch != '\n')
    {
        cout << ch;
        Rev();
    }
}
12. Given the following input:
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
15
23
21
19

 
< previous page page_1151 next page >