fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int isLegal (char theString[]) {
  5. int vowelCount = 0;
  6.  
  7. for (int i = 0; theString[i] != '\0'; i++){
  8. char c = toupper(theString[i]); // letters can be lowercase or uppercase
  9.  
  10. if (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U' || c == 'Y') {
  11. vowelCount++;
  12. }
  13. }
  14.  
  15. if (vowelCount > 0)
  16. return 1; // LEGAL
  17. else
  18. return 0; // NOT LEGAL
  19.  
  20. }
  21.  
  22. int main() {
  23. // your code goes here
  24.  
  25. char theString[100];
  26.  
  27. printf("Type a word: ");
  28. scanf("%s", theString);
  29.  
  30. if (isLegal(theString))
  31. printf("Legal Word");
  32. else
  33. printf("Illegal Word");
  34.  
  35. return 0;
  36. }
Success #stdin #stdout 0.01s 5324KB
stdin
sch
stdout
Type a word: Illegal Word