Monday 22 August 2011

LEX program to count number of vowels and consonants in a given input string

,
1 . PROGRAM TO IDENTIFY VOWELS AND CONSONANTS GIVEN AS  INPUT

 Algorithm:-

         begin

         if  a,e,I,o,u      or   A,E,I,O,U

         then

         printf “It is a vowel”

         else

         printf “It is a consonant”

         end

1.LEX program to count number of vowels and consonants in a given input string

%%

[aeiouAEIOU] {printf(“it is vowel”);}

[a-zA-Z] {printf(“it is consonant”);}

%%

main()

{

yylex();

}

int yywrap()

{

return 1;

}



Output:

$./a.out

a

it is a vowel

g

it is a consonant

0 comments to “LEX program to count number of vowels and consonants in a given input string”

Post a Comment