/* 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 Caesar cipher](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxSYsDbMUbtWqzmRF_YFaQPX7nhW9_KgbAwUEJBhHjluoMGdqPKwTOabrbb-mZ6pMYodZ9JJtzPguIgnIx8ba8SELwfY6JR4IHHmG7Zb6f9wYTDuot94Fd4wbLCHKbodXhpbaAS_BmaPk/s640/2b.png)
Caesar cipher
No comments:
Post a Comment