How to reverse alphabets in C++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to reverse alphabets in C++

Actually i want to write code which reverse every alphabets like Everyone to enoyrevE

3rd Nov 2020, 1:40 PM
Muhammad Fahad Bashir
Muhammad Fahad Bashir - avatar
3 Answers
+ 2
Post your attempt... Just using a loop will do that work..
3rd Nov 2020, 1:58 PM
Jayakrishna 🇮🇳
+ 2
#include <string> int main() { std::string word = "Everyone"; std::string reversedWord = ""; for(int i = word.length() - 1; i > 0; i--) { reversedWord.at(i - (word.length() - 1)) = word.at(i); } return 0; }
3rd Nov 2020, 1:59 PM
Donato Paul Thayalan
Donato Paul Thayalan - avatar
+ 1
Thanks #donato
4th Nov 2020, 12:24 PM
Muhammad Fahad Bashir
Muhammad Fahad Bashir - avatar