Loops

What will be the output of this source code?

They are asking as to find the output but is it depends on what the user entered, so it can be any words. I'm confused, please help me. (is the word the user entered is "word" as well)


int main()
{
string word;
cout << "please enter a word: ";
cin >> word;
int length = word.length();
int i = -1;

do
{
i++;
char ch = word[i];
word[i] = word[length-1];
word[length-1] = ch;
} while (i < --length - 1);

cout << word;
return 0;

}
First, cannot post homework on forums. Second run the code yourself.
They're asking what the program does to the input, not what every possible output is.
Thank you LB for explaining it
Topic archived. No new replies allowed.