%{
#include <stdio.h>
#include <string.h>
int vowels = 0; //declare vowels and assign 0 value to it
int consonants = 0; //declare consonants and assign 0 value to it
%}
%%
[aeiouAEIOU
] {vowels
++;} //check for vowels and increment it when found or
true [a
-zA
-Z
] {consonants
++;} //check for consonants and increment it when found or
true .|\n {} //ignore other characters
%%
int main(){
printf("Enter text\n");//asks for input
yylex(); //calls the lexical analyzer
printf("Vowels : %d", vowels);//print the number of vowels in the str
printf("\nConsonants : %d", consonants);//print the number of consonants in the str
}
int yywrap(){
return 0;//to tell that it was a success
}
JXsKICAgICNpbmNsdWRlIDxzdGRpby5oPgogICAgI2luY2x1ZGUgPHN0cmluZy5oPgoKICAgIGludCB2b3dlbHMgPSAwOyAgLy9kZWNsYXJlIHZvd2VscyBhbmQgYXNzaWduIDAgdmFsdWUgdG8gaXQKICAgIGludCBjb25zb25hbnRzID0gMDsgIC8vZGVjbGFyZSBjb25zb25hbnRzIGFuZCBhc3NpZ24gMCB2YWx1ZSB0byBpdAolfQoKJSUKClthZWlvdUFFSU9VXSAgICB7dm93ZWxzKys7fSAvL2NoZWNrIGZvciB2b3dlbHMgYW5kIGluY3JlbWVudCBpdCB3aGVuIGZvdW5kIG9yIHRydWUKW2EtekEtWl0gICAge2NvbnNvbmFudHMrKzt9IC8vY2hlY2sgZm9yIGNvbnNvbmFudHMgYW5kIGluY3JlbWVudCBpdCB3aGVuIGZvdW5kIG9yIHRydWUKLnxcbiAgICB7fSAvL2lnbm9yZSBvdGhlciBjaGFyYWN0ZXJzCgolJQoKaW50IG1haW4oKXsKICAgIHByaW50ZigiRW50ZXIgdGV4dFxuIik7Ly9hc2tzIGZvciBpbnB1dAogICAgeXlsZXgoKTsgLy9jYWxscyB0aGUgbGV4aWNhbCBhbmFseXplcgogICAgcHJpbnRmKCJWb3dlbHMgOiAlZCIsIHZvd2Vscyk7Ly9wcmludCB0aGUgbnVtYmVyIG9mIHZvd2VscyBpbiB0aGUgc3RyCiAgICBwcmludGYoIlxuQ29uc29uYW50cyA6ICVkIiwgY29uc29uYW50cyk7Ly9wcmludCB0aGUgbnVtYmVyIG9mIGNvbnNvbmFudHMgaW4gdGhlIHN0cgp9CgppbnQgeXl3cmFwKCl7CiAgICByZXR1cm4gMDsvL3RvIHRlbGwgdGhhdCBpdCB3YXMgYSBzdWNjZXNzCn0=