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:
- 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
- Lex Program to check whether a number is Prime or Not
- C Program to Check Whether a Number is Prime or not
- C++ Program to check Prime Number
- C Program to check Armstrong Number
- C program to Check Whether a Number is Positive or Negative or Zero
- Program to check if a number belongs to a particular base or not
- C Program to Check if all digits of a number divide it
- Lex program to check valid Mobile Number
- 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
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.