Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #define UP_A 65
- #define UP_Z 91
- #define LOW_A 97
- #define LOW_Z 122
- int main() {
- std::string word;
- std::string upper;
- std::string lower;
- std::string backwards;
- std::cout << "Enter word: ";
- std::cin >> word;
- //Lower To Upper:
- for (int i = 0; i < word.length(); i++) {
- if (word.at(i) >= LOW_A && word.at(i) <= LOW_Z) {
- upper += (word.at(i) - 32);
- }
- else {
- upper += word.at(i);
- }
- }
- //Upper To Lower:
- for (int i = 0; i < word.length(); i++) {
- if (word.at(i) >= UP_A && word.at(i) <= UP_Z) {
- lower += (word.at(i) + 32);
- }
- else {
- lower += word.at(i);
- }
- }
- //Reverse String:
- for (int i = word.length(); i > 0; i--) {
- backwards += word.at(i - 1);
- }
- //Print Data:
- std::cout << "Upper: " << upper << "\n";
- std::cout << "Lower: " << lower << "\n";
- std::cout << "Reversed: " << backwards << "\n";
- system("PAUSE");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement