[Solved] take a word from the user and prints it as shown below. Enter the word: Word d rd ord Word [closed]
To get the expected output, you can make the outer loop loop from word.length() – 1 down to 0 instead: #include <cstddef> // std::size_t #include <iostream> #include <string> int main() { std::cout << “Enter the word:”; if (std::string word; std::cin >> word) { for (auto i = word.length(); i–;) { // <- here for (std::size_t … Read more