Prerequisite: Flex (Fast lexical Analyzer Generator)
Given a string containing both vowels and consonants, write a LEX program to count the number of vowels and consonants in given string.
Input: Hello everyone Output: Number of vowels are: 6 Number of consonants are: 7 Input: This is GeeksforGeeks Output: Number of vowels are: 7 Number of consonants are: 12
Approach is very simple. If any vowel is found increase vowel counter, if consonant is found increase consonant counter otherwise do nothing.
Below is the implementation:
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
- Lex program to count the number of lines, spaces and tabs
- Lex program to check whether given number is armstrong number or not
- Lex Program to Identify and Count Positive and Negative Numbers
- Lex program to count the frequency of the given word in a file
- Lex program to check whether given string is Palindrome or Not
- Lex Program to count number of words
- Lex program to Count the Positive numbers, Negative numbers and Fractions
- Lex program to count words that are less than 10 and greater than 5
- Lex program to check whether a given number is even or odd
- Lex Program to remove comments from C program
- Lex Program to accept string starting with vowel
- Lex program to find the Length of a String
- Lex program to take input from file and remove multiple spaces, lines and tabs
- Lex program to recognize valid arithmetic expression and identify the identifiers and operators
- LEX program to add line numbers to a given file
- Lex Program to print the total characters, white spaces, tabs in the given input file
- Lex program to check whether input number is odd or even
- Lex Program to check whether a number is Prime or Not
- Lex program to check valid Mobile Number
- Lex code to count total number of tokens
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : ankita_chandra