0% found this document useful (0 votes)
8 views1 page

Count Upper and Lower Case Letters

This document contains code to count uppercase and lowercase letters in a string input by the user. It uses flex to define rules for uppercase and lowercase characters and prints the totals of each at the end.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Count Upper and Lower Case Letters

This document contains code to count uppercase and lowercase letters in a string input by the user. It uses flex to define rules for uppercase and lowercase characters and prints the totals of each at the end.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

%{

#include<stdio.h>

int upper = 0;

int lower=0;

%}

/* Rules Section*/

%%

[A-Z] {printf("upper cse\t");upper++;}

[a-z] {printf("lower case\t"); lower++;}

%%

int yywrap()

return 0;

main()

printf("enter a string\n");

yylex();

printf("uppercase=%d and lowercase=%d",upper,lower);

You might also like