title: Write a lex program that detects and counts the pattern that starts with an uppercase letter, ends with a lowercase letter
body: <p>I understood the problem and written the below code. My code works and it prints the number of detected valid and invalid patterns when I quit the program with <code>ctrl+z</code>.</p>
  <p><strong>Here is my code:</strong></p>
  <pre><code>%{
  int valid = 0;
  int invalid = 0;
  %}
  
  
  %%
  ([A-Z][a-zA-Z0-9]*[a-z])* {valid++;}
  [a-zA-Z0-9]* {invalid++;}
  %%
  
  
  int yywrap(){}
  
  int main(int argc, char **argv[])
  {
      printf(&quot;\n Enter inputs: \n\n&quot;);
      yylex();
      
      printf(&quot;\n\n\tNumber of VALID patterns   = %d\n&quot;, valid);
      printf(&quot;\tNumber of invalid patterns = %d\n\n&quot;, invalid);
  
      return 0;
  }
  </code></pre>
  <p><strong>But I want something like this:</strong></p>
  <ul>
  <li>It should print the detected patterns, number of valid patterns and the number of invalid patterns whenever I input a new line.</li>
  <li>There should be an EXIT command.</li>
  </ul>