Not a member of gistpad yet?
Sign Up,
it unlocks many cool features!
- // SpiderX Code
- #include <iostream>
- using namespace std;
- int main() {
- string str;
- cout << "Enter a string: ";
- getline(cin, str);
- // calculate length of string
- int strLen = str.length() - 1;
- // store reverse string
- string reversedStr = "";
- for (int i = strLen; i >= 0; i--) {
- reversedStr += str[i];
- }
- cout << "\nOriginal String: " << str << endl;
- cout << "Reversed string: " << reversedStr << endl;
- return 0;
- }
RAW Gist Data
Copied
