- Install Flex on Ubuntu/WSL with
sudo apt-get update
sudo apt-get install flex
- Run a lex file using
lex filename.l
This will generate a lex.yy.c file.
- Compile the C file using gcc and run.
gcc lex.yy.c
./a.out
Read the given input string. Check if there exists a number, if yes, convert it to binary using conventional method, and store it in a character array. End if new line is reached.
Read the given input string. Check each character and increment the array at the index of its ASCII code using yytext to store its count in the array. Find the maximum number in this array and print the frequency and index as character. End if new line is reached.
Read the given input string. Check if the first character is a numerical or any special character except ‘_’ and print invalid if true. Otherwise print it as valid identifier if remaining characters of string doesn’t contain any special characters except ‘_’.
Read the given input string. Check each word and store its length using yyleng in a max variable if its greater than previous value End if new line is reached.
Read the given input string. Check one character at a time until it is not empty. Check if the character is a vowel or a consonant and increment the respective variable. Print the number of vowels and consonants stored in respective variables.