Step 2 :- gcc lex.yy.c
Step 3 :- ./a.out
cv.l
%{
int vowel=0;
int const =0;
%}
%%
[aeiouAEIOU] {vowel++;}
[a-zA-Z] {const++;}
%%
int yywrap(){}
int main()
{
printf("Enter the string of Vowels and Consonents ::");
yylex();
printf("Number of vowels are : %d\n", vowel);
printf("Number of consonants are : %d\n", const);
return 0;
}
OUTPUT
sunny@sunny-PC:~/Desktop$ flex cv.l
sunny@sunny-PC:~/Desktop$ gcc lex.yy.c
sunny@sunny-PC:~/Desktop$ ./a.out
Enter the string of Vowels and Consonents :: Peace begins with a smile
press ctrl+d
Number of vowels are: 9
Number of consonants are: 12
No comments:
Post a Comment
Please do not any spam link in Comment Box