fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. void wordChecker(char userWord[]);
  5.  
  6. int main(void) {
  7.  
  8. char userWord[100];
  9.  
  10. scanf("%99s", userWord);
  11.  
  12. wordChecker(userWord);
  13. return 0;
  14. }
  15.  
  16.  
  17. void wordChecker(char userWord[]) {
  18.  
  19.  
  20. int i = 0; //array index
  21.  
  22. int wordLength = strlen(userWord);
  23.  
  24.  
  25. for (i; i < wordLength ;i++){
  26.  
  27. char ch = userWord[i];
  28.  
  29. if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'y' ||
  30. ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U' || ch == 'Y') {
  31. printf("the word you gave is a legal word!");
  32. return 0;
  33.  
  34. }//if any of the characters are a vowels
  35.  
  36. }//for loop for the whole string length
  37.  
  38. printf("the word you gave is not a legal word");
  39.  
  40.  
  41. }//wordChecker function
Success #stdin #stdout 0s 5320KB
stdin
sch
stdout
the word you gave is not a legal word