Palindrome
Completed
Read a word and print yes if it reads the same backwards (case-insensitive), else no. Build the reverse with string(s.rbegin(), s.rend()).
Input
One word.
Output
yes or no
Example
Input
Level
Output
yes
Editor
C++
Hints
rbegin()/rend() iterate backwards.
Strings compare with ==.
Solution explanation
Constructing a string from a pair of iterators copies that range of characters.
Show solution
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main() {
string s;
cin >> s;
for (char &c : s) c = tolower(c);
string reversed(s.rbegin(), s.rend());
cout << (s == reversed ? "yes" : "no") << "\n";
return 0;
}