/* Write a Lex program that implements the Caesar cipher: it replaces every letter
with the one three letters after in in alphabetical order, wrapping around at Z. e.g. a is replaced by d, b by e, and so on z by c. */
%% [a-z] {char ch = yytext[0]; ch += 3; if (ch> 'z') ch -= ('z'+1- 'a'); printf ("%c" ,ch ); } [A-Z] { char ch = yytext[0] ; ch += 3; if (ch> 'Z') ch -= ('Z'+1- 'A'); printf("%c",ch); } %%
// Output of the above program
Caesar cipher
No comments:
Post a Comment