text: Q:
  
  How do I prevent character from being printed twice inside for loop? c++
  
  This question looks similar to other questions (which I have checked.) However no question posed has the answer I'm looking for. 
  I am using C++ to write a program to check if a character out of a string is a vowel or a consonant and to use a counter loop to iterate over the string to produce the results. isalpha() is inside a bool function named 'isVowel' which only does 2 things. 1 It checks if the value checked is indeed a legal alphabet character. 2 It checks if the character is a vowel, if true, it returns true to main. I need to be pointed in the direction as to why my cout 'is vowel' is being printed twice below the original string in the for loop 'if (answer == true)' statement.
  #include <iomanip>
  #include <iostream>
  #include <string>
  #include <ctype.h>
  
  using namespace std;
  
  bool isVowel(char word){
      if(isalpha(word)){
          if(word == 'a' || word == 'A')
          {
              return true;
          }   
      }
      return false;
  }
  
  int main ()
  {   
      //Variables
  
      string choice;
      bool answer;
  
      //program starts here
      cout << setw(50) << "Vowels and Consonants" << endl;
      cout << "Please enter a word: ";
      cin >> choice;
  
      //while loop gathering each letter of the word to test for vowels/consonants
      /*while((unsigned)index < choice.length())*/
      for (int index = 0;(unsigned) index < choice.length();){
  
          char letter = choice[index];
          answer = isVowel(choice[index]);
          cout << letter <<  endl;
  
          if(answer != false){
              cout << letter << " is a vowel" << endl;    
          }
  
          index++;
      }
  
      return 0;   
  }
  
  A:
  
  You should change lines 36-40 with an expression like this: cout << letter << ((answer != false) ? " is a vowel\n" : "\n");
  
  