Tuesday, 11 February 2014

Caesar Cipher Algorithm Using c

#include<conio.h>
#include<stdio.h>
#include<string.h>
void main()
{
int i,l;
char pt[10],ct[10];
printf("Enter plain text: ");
gets(pt);
l=strlen(pt);
for(i=0;i<l;i++)
               {
ct[i]=pt[i]+3;
if(ct[i]>122)
{
ct[i]=ct[i]-26;
}
}
ct[i]=NULL;
printf("\ncipher text is: ");
puts(ct);

for(i=0;i {
pt[i]=ct[i]-3;
if(ct[i]
<97)
{
ct[i]=ct[i]+26;
}
}
printf("\n plain text is: ");
puts(pt);
getch();
}

1 comment: