Tuesday, 31 March 2020

It's time To increase blogging capability. To have a chance to contribute in digital world.

Any Interested People who want to make this blog more better that can be join via communicating to pdhavz@gmail.com


Sunday, 16 June 2019

Write a LEX program to check whether input symbol is number or character.


            

               Code :

%{
%}
%%
[0-9] {printf("Input is a number");}
[A-Za-z] {printf("Input is a character");}
%%
main()
{
     yylex();
}
int yywrap()
{
     return 1;
}

Write a LEX program to check whether input is multidigit number or string.


              

               Code :

%{
%}
%%
[0-9][0-9]+ {printf("Input is a multi digit number");}
[A-Za-z][A-Za-z]+ {printf("Input is a multi character");}
%%
main()
{
     yylex();
}
int yywrap()
{
     return 1;
}

Write a LEX program to check whether inputted character is vowel or not.


            

               Code :

%{
%}
%%
[aeiouAEIOU]              {printf("Input is a vowel");}
[A-Za-z(^aeiouAEIOU)]     {printf("Input is not a vowel");}
%%
main()
{
     yylex();
}
int yywrap()
{
     return 1;
}

Write a LEX program to count only those words that start with vowels.


              

               Code :

%{
%}
%%
[aeiouAEIOU][A-Za-z]+              {printf("Word starting with vowel");}
[A-Za-z(^aeiouAEIOU)][A-Za-z]+      {printf("Word not starting with vowel");}
%%
main()
{
     yylex();
}
int yywrap()
{
     return 1;
}

Write a LEX program to count number of vowels from all inputted symbols.


              

               Code :

%{           
     int count_v;
%}
%%
[aeiouAEIOU]           {count_v++;}
%%
main()
{
     yylex();
     printf("Count of vowels= %d\n",count_v);
}
int yywrap()
{
     return 1;
}

It's time To increase blogging capability. To have a chance to contribute in digital world. Any Interested People who want to make t...