Given a number n, the task is to check whether the given n is even or odd using Lex program.
Input : 10 Output : Even Input : 5 Output : Odd
Prerequisite: FLEX (Fast Lexical Analyzer Generator)
An even number is an integer which is “evenly divisible” by 2. This means that if the integer is divided by 2, it yields no remainder or 0 as remainder. Similarly, an Odd number is an integer which is not “evenly divisible” by 2 and will leaves 1 as remainder.
Below is the implementation of above approach:
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 check whether input number is odd or even
- Lex program to check whether given number is armstrong number or not
- DFA in LEX code which accepts Odd number of 0’s and even number of 1’s
- DFA in LEX code which accepts even number of zeros and even number of ones
- Lex program to check whether given string is Palindrome or Not
- Lex Program to check whether a number is Prime or Not
- Lex program to check whether the input is digit or not
- Lex program to check whether an year is a leap year or not
- Lex program to check valid Mobile Number
- LEX program to count the number of vowels and consonants in a given string
- Lex Program to check valid email
- Lex program to check perfect numbers
- Lex program to check if a Date is valid or not
- Lex Program to remove comments from C program
- 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 count the frequency of the given word in a file
- Lex Program to count number of words
- Lex program to count the number of lines, spaces and tabs
- Lex Program to Identify and Count Positive and Negative 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.