Problem: Write a Lex program to check whether an year is a leap year or not.
Lex is a computer program that generates lexical analyzers and was written by Mike Lesk and Eric Schmidt. Lex reads an input stream specifying the lexical analyzer and outputs source code implementing the lexer in the C programming language.
Note: Leap years are the years that are divisible by 400 or are divisible by 4 and not divisible by 100. So 2016, 2020 etc are leap years while 2017 and 2019 are not.
Input: 2016 Output: leap year Input: 2017 Output: not a leap year
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 the input is digit or not
- Lex Program to check whether a number is Prime or Not
- Lex program to check whether given string is Palindrome 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 input number is odd or even
- Lex program to check if a Date is valid or not
- Lex Program to check valid email
- Lex program to check perfect numbers
- Lex program to check valid Mobile Number
- Lex Program to remove comments from C program
- LEX program to add line numbers to a given file
- Lex Program to Identify and Count Positive and Negative Numbers
- Lex Program to count number of words
- Lex Program For checking a valid URL
- Lex program to take input from file and remove multiple spaces, lines and tabs
- Lex program to count the number of lines, spaces and tabs
- Lex program to identify the identifier
- Lex Program to accept a valid integer and float value
- Lex Program to accept string starting with vowel
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.