code.cpp 326 B

123456789101112
  1. /* Create a function that takes a word
  2. ~ and returns true if the word has two consecutive identical letters.
  3. */
  4. bool double_letters(std::string word) {
  5. for (int i=0;i<word.size();i++){
  6. // get current character of "word", compare with next character
  7. if (word[i] == word[i+1]) {
  8. return true;
  9. }
  10. }
  11. return false;
  12. }