%{ #include<stdio.h> #include<stdlib.h> int i; %} %% [0-9]+ {i=atoi(yytext); if(i%2==0) printf("Even !"); else printf("Odd !");}; %% int main() { yylex(); } /*Â To Compile :- 1) lex filename.l 2) gcc lex.yy.c -ll 3) ./a.out Enter Input and press enter */
Output :-
145
Odd !
204
Even !