in Compilers, Architecture, HPC
758 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
758 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

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true