Expand|Select|Wrap|Line Numbers
- int main()
- {
- cout << "---------------------------------------------------------" << endl;
- cout << " Letter Swapping Program" << endl;
- cout << "---------------------------------------------------------" << endl;
- string word;
- cout << "Please enter a word at least 3 letters long: ";
- cin >> word;
- cout << endl << endl;
- int wordLen = word.length();
- char firstLet = word.at(0);
- char lastLet = word.back();
- cout << "The length of " << word << "is " << wordLen << endl;
- cout << "The first and last letters of " << word << " are " << firstLet << " and " << lastLet << " respectively." << endl;
- cout << "If you swap the first and last letters of this word, you get: ";
Thanks!