0% found this document useful (0 votes)
122 views1 page

Write A Program in Lex To Identify Whether Letter Is Consonant or Vowel. Code

This document provides a code sample in Lex to write a program that identifies whether an input letter is a consonant or vowel. The program takes a letter as input, uses regular expressions to match the letter pattern, and prints either "consonent" or "vowel" based on the match. It is a simple lexical analyzer program to classify letters.

Uploaded by

shinjo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
122 views1 page

Write A Program in Lex To Identify Whether Letter Is Consonant or Vowel. Code

This document provides a code sample in Lex to write a program that identifies whether an input letter is a consonant or vowel. The program takes a letter as input, uses regular expressions to match the letter pattern, and prints either "consonent" or "vowel" based on the match. It is a simple lexical analyzer program to classify letters.

Uploaded by

shinjo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Laboratory Assignment Sheet

1. Write a program in Lex to identify whether letter is consonant or vowel.


Code:
%option noyywrap
%{
#include<stdio.h>
%}

%%
["a"|"e"|"i"|"o"|"u"|"A"|"E"|"I"|"O"|"U" ] {printf(" vowel");}
[a-z|A-Z] {printf(" consonent");}
%%

int main()
{
printf("Enter Word: ");
yylex();
return 0;
}

Output:

You might also like