lex program to count the number of words

%{
#include <stdio.h>;
#include <string.h>;
int i=0;
%}
%%
([a-z]|[A-Z][0-9])*    {i++;}
"\n" {printf("%d\n",i);i=0;}
%%
main()
{
yylex();
return 0;
}
int yywrap()
{
}

Sample output

pls check the output
4

Digiprove sealCopyright secured by Digiprove © 2018-2020 Humble Chirammal