#include #include using namespace std; int main() { // 11 // 012345678901 string phrase = "Hello World!"; int i; cout << "The phrase \"" << phrase << "\" is " << phrase.size() << " characters long." << endl; cout << "The first letter is '" << phrase.front() << "'." << endl; cout << "The last letter is '" << phrase.back() << "'." << endl; cout << endl; i = 0; while ( i < phrase.size()) { cout << "letter " << i << " is " << phrase[i] << "." << endl; if (isblank(phrase[i])) { cout << "By the way, that is a blank." << endl; } if (isalpha(phrase[i])) { cout << "By the way, that is a letter." << endl; } i++; } cout << endl; i = 0; while ( i < phrase.size()) { //phrase[i] = 'x'; phrase[i] = toupper(phrase[i]); cout << "In the loop, i = " << i << endl; cout << "The phrase is \"" << phrase << "\"." << endl; cout << endl; i++; } cout << endl << endl; // 11 // 012345678901 //string phrase = "Hello World!"; i = phrase.size()-1; while ( i >= 0 ) { cout << phrase[i]; i--; } cout << endl; return 0; }