Friday, April 12, 2019

Lex program to differentiate mobile number and land line number. (Note : Both mobile and land line numbers have 10 digits but land line number starts with digit 0 to 6 and mobile number has starting digit 7 to 9.)


%{
#include<stdio.h>
%}
%%
[7-9].*{9} {printf("Mobile no");}
[0-6].*{9} {printf("lanline no");}
.* {printf("invalid");}
%%
main()
{
yylex();
}

ScreenShot:


No comments:

Post a Comment