Skip to content

Instantly share code, notes, and snippets.

@2hanX
Last active June 17, 2020 05:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 2hanX/051781c3094c5535c323938e3f34cf0f to your computer and use it in GitHub Desktop.
Save 2hanX/051781c3094c5535c323938e3f34cf0f to your computer and use it in GitHub Desktop.
#include<iostream>
#include<string>
using namespace std;
int main()
{
cout << "Enter a word: ";
string word;
cin >> word;
char temp;
int i, j;
for ( j = 0, i = word.size()-1; j < i; --i, ++j)
{
temp = word[i];
word[i] = word[j];
word[j] = temp;
}
cout << word << "\nDone\n";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment