#include<stdio.h>
#include<conio.h>
void main()
{
int i,j=0,k=0;
char str[50],en[100],dc[100];
printf("Enter the string : ");
gets(str);
for(i=0;i<strlen(str);i++)
{
if((str[i]-17)<=57 && (str[i]-17)>=48) //For capital letters
{
//printf("\nStr: %c",str[i]);
en[j]=48;
j++;
en[j]=str[i]-17;
//printf("\nEn : %c",en[j]);
j++;
}
else if((str[i]-17)>=58 && (str[i]-17)<=67)
{
//printf("\nStr: %c",str[i]);
en[j]=51;
j++;
en[j]=str[i]-27;
j++;
//printf("\nEn : %c",en[j]);
}
else if((str[i]-17)>=68 && (str[i]-17)<=73)
{
//printf("\nStr: %c",str[i]);
en[j]=53;
j++;
en[j]=str[i]-37;
j++;
//printf("\nEn : %c",en[j]);
}
else if((str[i]-49)<=57 && (str[i]-49)>=48) //For small letters
{
//printf("\nStr: %c",str[i]);
en[j]=50;
j++;
en[j]=str[i]-49;
j++;
//printf("\nEn : %c",en[j]);
}
else if((str[i]-49)>=58 && (str[i]-49)<=67)
{
//printf("\nStr: %c",str[i]);
en[j]=52;
j++;
en[j]=str[i]-59;
j++;
//printf("\nEn : %c",en[j]);
}
else if((str[i]-49)>=68 && (str[i]-49)<=73)
{
//printf("\nStr: %c",str[i]);
en[j]=56;
j++;
en[j]=str[i]-69;
j++;
//printf("\nEn : %c",en[j]);
}
else
{
en[j]=55;
j++;
en[j]=str[i]-57;
j++;
}
}
printf("\nOriginal String : ");
puts(str);
printf("\nEncrypt String : ");
puts(en);
for(i=0;i<strlen(en);i++)
{
if(en[k]==48) //For capital letters
{
dc[i]=en[k+1]+17;
k=k+2;
}
else if(en[k]==51)
{
dc[i]=en[k+1]+27;
k=k+2;
}
else if(en[k]==53)
{
dc[i]=en[k+1]+37;
k=k+2;
}
else if(en[k]==50) //For small letters
{
dc[i]=en[k+1]+49;
k=k+2;
}
else if(en[k]==52)
{
dc[i]=en[k+1]+59;
k=k+2;
}
else if(en[k]==56)
{
dc[i]=en[k+1]+69;
k=k+2;
}
else if(en[k]==55)
{
dc[i]=en[k+1]+57;
k=k+2;
}
}
printf("\nDecrypted String : ");
puts(dc);
getch();
}
: Output :

