fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. char word[100];
  5.  
  6. printf("Enter a word: ");
  7. scanf("%s", word);
  8.  
  9. if (is_legal_word(word)) {
  10. printf("'%s' is legal.\n", word);
  11. } else {
  12. printf("'%s' is illegal.\n", word);
  13. }
  14.  
  15. return 0;
  16. }
  17.  
  18.  
  19. int is_legal_word(const char *word) {
  20. while (*word != '\0') {
  21. char ch = tolower(*word);
  22. if (ch == 'a' || ch == 'e' || ch == 'i' ||
  23. ch == 'o' || ch == 'u' || ch == 'y') {
  24. return 1; // Legal contains at least one vowel
  25. }
  26. word++;
  27. }
  28. return 0; // Illegal no vowels found
  29. }
  30.  
Success #stdin #stdout 0s 5324KB
stdin
try
stdout
Enter a word: 'try' is legal.