in Compilers, Architecture, HPC
479 views
0 votes
0 votes
%{
    #include<stdio.h>
    int vowels=0;
    int cons=0;
%}
%%
[aeiouAEIOU] {vowels++;}
[a-zA-Z] {cons++;}
%%
int yywrap()
{

return 1;
}
int main( )
{
 printf("Enter the string..at end press^d\n");
 yylex();
 printf("No of vowels = %d \n No of consonants = %d\n",vowels,cons);
 return 0;
}

when i run this program in ubuntu . iam able to enter the string but it does print the line for counting vowels and consonants
in Compilers, Architecture, HPC
479 views

4 Comments

Is your question is

No.of Consonants is printing wrong?
0
0
No...it prints nothing ,i can only enter the string
0
0
@Shaik

how u dry running it?
0
0
in my B.Tech, i write more lex programs, from that experience i am running it...

He made mistake in Forming Regular Expression for Consonants.

But i am not getting why this code is doesn't give any output...

It should atleast print "No.of Vowels" etc...

right now, I didn't have lex compiler.. that's why i am not able to answer it.
0
0

Please log in or register to answer this question.

Related questions