#include <stdio.h>
#include <string.h>
//**************************************************************
// Function: isLegal
//
// Purpose: Determine if a given word is legal
//
// Parameters:
//
// theString - string/word that determining if legal or not
//
// Returns: whether legal (1=legal, 0=not legal)
//
//**************************************************************
int isLegal ( char theString[ ] ) {
char vowels[ ] = { 'a' ,'e' ,'i' ,'o' ,'u' ,'y' ,'A' ,'E' ,'I' ,'O' ,'U' ,'Y' } ;
int numVowels= 0 ; //initializing the variable that will hold the number of vowels
for ( int i= 0 ; theString[ i] ! = '\0 ' ; i++ ) { //looping through the characters in the string being searched
for ( int j= 0 ; j< strlen ( vowels) ; j++ ) { //looping through the list of vowels in the vowels array
if ( theString[ i] == vowels[ j] ) { //checking if the current character from theString (i.e., the one associated with the current iteration of the outer loop) is equal to the vowel (i.e. the current value in the inner loop)
numVowels+ = 1 ;
}
}
}
int legal= 0 ;
if ( numVowels>= 1 ) {
legal= 1 ; //if at least 1 vowel, then word is legal
}
return legal;
}
int main( ) {
int legalYN= isLegal( "try" ) ;
printf ( "Is legal, 1=yes, 2=no: %i\n " , legalYN) ;
return 0 ;
} ;
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KCi8vKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKLy8gRnVuY3Rpb246IGlzTGVnYWwKLy8gCi8vIFB1cnBvc2U6IERldGVybWluZSBpZiBhIGdpdmVuIHdvcmQgaXMgbGVnYWwKLy8gCi8vIFBhcmFtZXRlcnM6Ci8vIAovLyAgICAgdGhlU3RyaW5nIC0gc3RyaW5nL3dvcmQgdGhhdCBkZXRlcm1pbmluZyBpZiBsZWdhbCBvciBub3QKLy8KLy8gUmV0dXJuczogd2hldGhlciBsZWdhbCAoMT1sZWdhbCwgMD1ub3QgbGVnYWwpCi8vICAKLy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgoKaW50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