#include #include using namespace std; // Function to reverse the order of words in a string string reverse_word_order(string const &str) { stringstream ss(str); string reversed = "", word; while (ss >> word) { // Read each word and prepend it to the result string reversed = word + " " + reversed; } if (!reversed.empty()) { // Remove trailing space, if any reversed.pop_back(); } return reversed; } int main() { string sentence = "The weather is so sunny nowadays"; cout << "Before: " << sentence << endl; cout << "After: " << reverse_word_order(sentence) << endl; return 0; }