Lex Program to Check String Palindrome

This is the lex program to check whether the given string is palindrome or not.

[cc lang=”c”]
%{
#include
char num,temp[100];
int rev=0;
char arr[100];
%}
%%
. scanf(“%s”,arr); temp=arr; while(temp!=0){rev=rev*10+(temp%10); temp/=10;} if(rev==num) printf(“PALI”); else printf(“NO”); clear();
%%
clear(){rev=0;}
main(){yylex();}
[/cc]

You may also like...

1 Response

  1. Guarav kumar says:

    Programs is working fine but how to do the same using file handling

Leave a Reply

Your email address will not be published. Required fields are marked *