It is an encryption technique in which each plaintext letter is to be replaced with one a fixed number of
(key=3), so that a B in the plaintext becomes E in the ciphertext.
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <ctype.h>
void main()
{
clrscr();
char message[80],ciphertext[80],decryptedtext[80];
int i;
printf("Enter original message : ");
scanf("%[^\n]",message);
for(i=0; i<strlen(message); ++i)
{
if(isalpha(message[i]))
{
if((message[i]+3)>'z')ciphertext[i]='a'+message[i]+3-'z'-1;
else ciphertext[i]=message[i]+3;
}
else
{
ciphertext[i]=message[i];
}
}
ciphertext[i]='\0';
printf("Cipher text : %s\n",ciphertext);
getch();
}
#include <conio.h>
#include <string.h>
#include <ctype.h>
void main()
{
clrscr();
char message[80],ciphertext[80],decryptedtext[80];
int i;
printf("Enter original message : ");
scanf("%[^\n]",message);
for(i=0; i<strlen(message); ++i)
{
if(isalpha(message[i]))
{
if((message[i]+3)>'z')ciphertext[i]='a'+message[i]+3-'z'-1;
else ciphertext[i]=message[i]+3;
}
else
{
ciphertext[i]=message[i];
}
}
ciphertext[i]='\0';
printf("Cipher text : %s\n",ciphertext);
getch();
}