#include <iostream>
#include <string>
// Function to reverse a string
std::string reverseString(const std::string& str) {
std::string reversedStr;
// Iterate through the characters of the input string in reverse order
for (int i = str.length() - 1; i >= 0; --i) {
// Append each character to the reversed string
reversedStr += str[i];
}
return reversedStr;
}
int main() {
// Input string
std::string inputStr;
// Prompt the user to enter a string
std::cout << "Enter a string: ";
std::getline(std::cin, inputStr);
// Call the function to reverse the string
std::string reversed = reverseString(inputStr);
// Display the reversed string
std::cout << "Reversed string: " << reversed << std::endl;
return 0;
}