Question: I wrote this code to read string in revers, but for some reason it doesn't want to read it right. Can you tell me what

I wrote this code to read string in revers, but for some reason it doesn't want to read it right. Can you tell me what is the issue;

#include

#include

#include

using namespace std;

int main() {

string uText;

string otvet = "";

cin >> uText;

int x = uText.size()-1;

getline(cin, uText);

while (uText == "Quit" || uText == "quit" || uText == "q") {break;}

for(int i = x ; i >= 0; --i)

{

otvet.push_back(uText.at(i));

}

cout << otvet << endl;

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!