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:
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Lex program to check whether given number is armstrong number or not
- Lex Program to check whether a number is Prime or Not
- Lex program to check whether input number is odd or even
- Lex program to check valid Mobile Number
- C program to check syntax of 'for' loop
- Lex program to check whether given string is Palindrome or Not
- Lex program to check perfect numbers
- Lex program to check if a Date is valid or not
- Lex program to check whether the input is digit or not
- Lex Program to check valid email
- YACC program to check whether given string is Palindrome or not
- Lex Program to count number of words
- Lex program to check whether an year is a leap year or not
- Lex program to count the number of lines, spaces and tabs
- LEX program to count the number of vowels and consonants in a given string
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.