Lex is a computer program that generates lexical analyzers. Lex reads an input stream specifying the lexical analyzer and outputs source code implementing the lexer in the C programming language.
The commands for executing the lex program are:
lex abc.l (abc is the file name) gcc lex.yy.c -ll ./a.out
Let’s see lex program to check whether input number is odd or even.
Input : 22 Output : Input Number is Even Input : 53 Output : Input Number is odd
Below is the implementation:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Lex program to check whether the input is digit or not
- Lex program to check whether given number is armstrong number or not
- Lex program to check whether a given number is even or odd
- C++ Program to check Prime Number
- C Program to check Armstrong Number
- C Program to Check Whether a Number is Prime or not
- Lex Program to check whether a number is Prime or Not
- Program to check if a number belongs to a particular base or not
- Lex program to check valid Mobile Number
- C program to Check Whether a Number is Positive or Negative or Zero
- C Program to Check if all digits of a number divide it
- C/C++ Program to check whether it is possible to make a divisible by 3 number using all digits in an array
- Program to find out the data type of user input
- Lex program to take input from file and remove multiple spaces, lines and tabs
- Lex Program to print the total characters, white spaces, tabs in the given input file
- Lex Program to check valid email
- C Program to Check if count of divisors is even or odd
- C program to check syntax of 'for' loop
- C program to check if a given string is Keyword or not
- Lex program to check perfect numbers
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.