How to check whether an alphabet character is a vowel or not in C++

1 Answer

0 votes
#include <iostream>

int main(void) {
    char ch = 'i';
      
    int vowel = (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || 
                 ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U');
  
    if (vowel)
        std::cout << "vowel";
    else
        std::cout << "not a vowel";

    return 0;
}
  
   
   
   
/*
run:
   
vowel
   
*/

 



answered Feb 13, 2021 by avibootz

Related questions

3 answers 265 views
2 answers 291 views
1 answer 192 views
...