fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. string first = "Bart";
  9. string last = "Simpson";
  10.  
  11. cout << first << endl; // prints out Bart
  12.  
  13. first[1] = 'r';
  14. cout << first << endl; // prints out Brrt
  15.  
  16. first[2] = 'a';
  17. cout << first << endl; // prints out Brat
  18.  
  19. first[1] = 'a';
  20. first[2] = 'r';
  21. cout << first << endl; // prints out Bart
  22.  
  23. if ((first[0]>='A') && (first[0]<='Z'))
  24. cout << first << " starts with an upper case letter" << endl;
  25. else
  26. cout << first << " does not start with an upper case letter" << endl;
  27.  
  28. return 0;
  29. }
Success #stdin #stdout 0.01s 2856KB
stdin
Standard input is empty
stdout
Bart
Brrt
Brat
Bart
Bart starts with an upper case letter