Monday 22 August 2011

LEX:PROGRAM TO RECOGNIZE STRINGS ENDING IN 00

,
  • PROGRAM TO RECOGNIZE STRINGS ENDING IN 00
 Algorithm:-
        begin
        if string=[0-9]*00
        then
        printf “string accepted”
        else
        printf”string rejected”
        end
3. LEX program to recognize strings ending in 00
 %%
[0-9]*00{printf(“string accepted”);
[0-9]*{printf(“string rejected”);}
%%
main()
{
yylex();
}
int yywrap()
{
return 1;
}
Output:

$./a.out
10100
String accepted
34560
String rejected

0 comments to “LEX:PROGRAM TO RECOGNIZE STRINGS ENDING IN 00”

Post a Comment